I guess you are experiencing primary exercise headaches that occur most often in young men in their 20s.
One of the reason for this headache can be low blood sugar, as you noticed eating after exercise can make headache less intense. So, you can try a glucose tablete before you begin, and then have a starchy snack or better yet a full meal soon after you finish (within an hour).
Do you suffer from migraine headache, too?
Do you usually see flashing lights before the actual headache?