Stop masturbating and see if that solves your headache.. If not see a DR.
It is true, masturbation does not cause headache. There are many causes for headache. Even if your vision is defective and you are not using glasses you may get headache. It may be due to the meningitis you had in the past.
Do slow abdominal breathing to calm down your sexual arousal. You may reduce the number of masturbation.Google abdominal breathing and learn and practice deep abdominal breathing.there is video on breathing in this thread. Search it in this thread.
haedache is not related to masturbation.