To my knowledge there is no built-in method to block access to mailboxes based on specific time period.
It is possible with running scheduled scripts to disable access on weekends then re-enable access on workdays in Exchange Online, but it is very complicated and may sometimes have delay to take effect.
If the main concern here is to prevent users from accessing their mailboxes data from home or other places (outside office), I would suggest using conditional access policy to create ip based policy to block access from other locations.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.