Hi, welcome to HCM. Thanks for asking your query at this forum.
We understand your concern. I have read your question carefully and understood it. I will try my best to answer it.
Masturbation is considered a
safe sex practice, but if it becomes a compulsory act then it becomes a problem. Within a limit it is not harmful. But if you are tired you may delay it for few hours, because tired body requires relaxation and masturbation may further make you more exhausted.
I can imagine the agony you are experiencing. As you accept that you get diverted from your goal and indulge in porn sites and masturbation. If you seriously feel that you are unable to control this habit, then it is time to change.
I Suggest you to follow a healthy lifestyle in the form of getting up from bed before sunrise, going for a walk/jog, doing meditation/yoga/ relaxation exercise for some time, having balanced healthy diet, having some time for recreation and socialization, listening to soothing music at evening and getting enough rest and sleep. You should actively engage in other pleasurable activities like games and sport, watching favourite TV serial, listening to your favourite music whenever you feel urge to masturbate.
Go offline for few days and see how it works. You may sacrifice your privacy for some time to avoid have check on this habits.
Even after following the above mentioned measures for few weeks if you do not get desired results, then you need to be prescribed some psychotropic medicines and/or
psychotherapy to control your urge.
I hope it answers your query.
I wish you all the best.