I just clicked the answer I clicked to answer this question.
I don't know if masturbating will cure a headache although it might by drawing your attention away from your pain and focusing it on your pleasure.
But there is a proven way for dealing with a headache without using drugs.
You sit down in a comfortable chair and clear your mind.
Then you ask yourself and answer the following series of questions:
1.) Where is my headache?
2.) How big is my headache?
3.) What shape is my headache?
4.) How many sides does my headache have?
5.) What color is my headache?
You just keep asking and answering these questions over and over and, as you do, you will notice that the size decreases, the color goes from bright red to pale blue or pastel grey, the shape becomes more smoothe, etc..
As you do this, you are slowly drawing your attention away from your headache/pain and focusing your attention on other things.
This takes practice, determination, and patience to perfect but it works and is a handy tool to have when you are somewhere where there isn't any aspirin or other medication.