I would highly recommend your friend see his doctor to diagnose his headaches. Caffeine often helps severe headaches as well as migraines, but abrupt withdrawal from caffeine also causes headaches. However, neither of these would specifically occur during intercourse.
A friend of mine recently reported getting a headache so severe during intercourse that he had to stop what he was doing until it passed in a few minutes. It was so bad that he is afraid it may be serious. Any ideas on what it might be?