Couple of things that cross my mind;
- Remember why you want it (is this a necessary working area at all? If yes, you should remember your motivation)
- Be kind to yourself. Do not punish or harm yourself. If there was no Buddhism, which would you rather want to be: The conservative Christian who says you go to hell for masturbation and you should feel guilty, or the scientist who says it is a proven way to release stress and get rid of anxiety? In my opinion it is better to indulge in both temptation A and in temptation B with moderation, than to abstain from A completely, fanatically, while still having B (and there always is a B in life). Seriously, ban it from your life and you will notice you'll find a substitute desire, like food or smoke or whatever. Maybe differentiate between: This time food/entertainment/sexual activity is reasonably 'necessary' and an act of kindness towards myself, and this time I'm grateful to have this learning opportunity to make some good karma by taking a new course of action by not doing it. Middle way is where it's at!
- Contemplate the notion of impermanence or simply watch the breath. For me personally that helps a great deal when I feel sad, maybe it would work for your problem as well.
(I'm obviously not a teacher or anything so I'm posting this both to help you and to recieve help from anyone who disagrees with anything I wrote)
Another point: According to Ajahn Brahm, when it comes to sexual desire, restricting your access to things (access as in: even being able to see girls) does not work. It will simply lower the threshold for the desire to arise.
And maybe the way is not to refrain but to progress to a state where the conditions for the desire to arise in the first place dissolve? I think I've heard Yuttadhammo about this, but I can't remember which video.
Best of luck in your development!