I had an issue like this 10 years ago. It turns out it was from hurting my neck and it shifting a blood vessel near a nerve. So when I got my heart rate up the blood vessel expands and gives a head ache feeling, then goes away as the blood vessel gets smaller and stops pushing against the nerve...