Try to give it up , I don't know about the headaches, but you will be glad you did. Take it from someone who had similar addiction
Hi Al, If your trying to give up masturbating, is it because your over masturbating? you may just have to live with the headaches till your body can adjusts to your new life, cold turkey, I dont think you will find drugs that would help and a shrink, at 17 for masturbating, I'm not sure you would want to go that way, the best thing would be to slowly extend your time between masturbating, again its all down to your body accepting what your doing.
Good Luck