Hello and welcome to eHealth Forum!
If your jaw and head hurt at the same time it is quite possible that the TMJ is causing the headache. TMJ by itself can also cause a headache or it can be the trigger of a migraine headache. On net it is difficult to comment on the actual cause.
Try massaging the various muscles of the face, shoulders, and back of the neck that may be involved. Locate and massage the painful spots with hard, slow, short strokes. Do this several times a day until the muscle is no longer painful when pressed.
To massage the masseter muscles (on the cheek) on each side of your upper jaw , place your thumb inside your mouth and squeeze the thick muscle in your cheek with your fingers. Use your index finger to probe the tender areas behind the teeth and to massage these spots.
Other home-care therapies, such as moist heat or cold packs on the face, vitamin supplements, or biofeedback can also be tried. Exercising several times each week, yoga or deep breathing exercises may help you relax. Drink plenty of fluids and water (not caffeine), eat fresh fruits and vegetables and keep yourself busy throughout the day.
On the other hand the headache may be a migraine attack only and you would need to try various medications to see which helps you best. There are many OTC products available. Needless to say it would be best if you could consult a doctor. Hope this helps. Take care!