Chronic pain is quite a complex area of study but there is a progressively growing body of evidence for the use of exercise as a tool in treating migraines and tension-type headaches. Upwards of 4% of the population suffers from headaches which is quite a considerable number of people when you think about it. Interestingly there has been a strong association between lack of physical activity and the increased prevalence of migraines and non-migraine headaches.
So we should move more!
More specifically to prevent migraines, it was found that almost any aerobic exercise is effective in reducing the frequency and quality of life. It is achieved through the release of natural pain killers (opiods),serotonin (the feel good hormone), and also has huge effects on a persons psychological state .
Although there is strong evidence for the use of exercise to prevent migraines about 44% of people who get them report an increased severity if they exercise during an attack. So it is best to exercise once the attack is over. The use of fitness to reduce the intensity of the migraine can take upwards of 3 months of exercising 2-3 times a week for 40 minutes so be patient.
For chronic tension-type headaches the best results in reducing their intensity and frequency is to perform resistance exercises that focus on shoulders and neck.
One of the biggest issues that most people run in to is that resistance exercise tends to increase the severity of the headaches immediately after a workout; so it is a matter of a long term benefit when integrating this type of exercise in prevention.
A study found that a progressive switch between high aerobic exercise and low resistance exercise to low aerobic and high resistance exercise over the course of 10 weeks allowed for the decrease in acute pain experienced by most people.
So it is possible to reduce the frequency and severity of headaches and migraines with the use of exercise. As a word of caution you should get an assessment by a medical professional to determine the root cause of the headaches you are experiencing. Headaches from illnesses like fibromyalgia, chronic whiplash, myalgic encephalomyelitis, and chronic fatigue have been found to be worsened by exercise.