There are a number of tools that can help you with that. I would suggest looking for tools that block certain websites for certain times.
StayFocusd for example is a Chrome extension that blocks websites for you, on which you spend too much time.
[Freedom](https://freedom.to/?utm_source=frdmblg) is an app that blocks websites and apps that you use too much. It's available for Windows & Mac.
There are more tools, you can easily find them yourself, but I think this should already get you started.