Migraine "triad" In addition to dr. Heller's excellent preceding answer to your question, please also consider that a clinical triad is often recognized that links ibs with migraines and fibromyalgia. As such, please pursue more formal evaluation of your headaches in this context, so that anti-migraine medication can be prescribed as appropriate.
Acetaminophen, NSAID. Can use the usual headache type pain relievers, such as acetaminophen, nsaids like ibuprofen. Perhaps the headaches are also due to stress or your reaction to it. May do better longterm with stress reduction techniques, e.g. Meditation, yoga, relaxation exercises, biofeedback; these can be helpful in ibs as well.