Headaches can have many causes. If it's related to an upset stomach, then invariably it's due to gas. This can be relieved by taking any medicines that can cure your upset stomach.
However, if it's due to cold, the remedy is to go for home remedies first like honey, basil and ginger or some medicines as prescribed by the doctor.
For headaches due to migrain the best remedy is yoga.