I started getting them a few years ago. First time was when doing leg presses. I went straight home and took advil and tried to rest. It finally went awy and I feel asleep. the next time I went to the gym pain came back when warming up for my bench. This continued for over a month. About 50% of my workouts were cut short form the headaches and each time I had sex the pain came back. It was from the back of my neck into the back of my head. I finally went to the doctor, I waited so long because I didn't have insurance. He ordered a cat scan, nothing was found. Eventually the headaches just went away, but I was miserable for about 1.5 months. The pain has came back on 3 separate occassions, each time when doing leg presses. I'm still scared they'll come back each time I do presses. When I do the presses now I make sure to keep my head back against the bench through the lift. So far this has worked.
You might want to try excederine migraine. It was the only thing that helped me once the pain started.