Hello and welcome to e health forum.
Orgasm is usually associated with elevated blood pressure and heart rate and hence increased flow of blood into the cerebral blood vessels, which might be the cause of your persistent headache after intercourse.
Usually such headaches subside in 30 minutes, but in cases, where it occurs more frequently and lasts for hours, it can be prevented with prophylactic medications like propranolol. In case it is occasional then medications like Indomethacin, an anti-inflammatory, or triptans, a class of anti-migraine medication, can be taken an hour or so before sex to ward off headaches.
For proper diagnosis and prescription of the above medications , you might consult your primary physician and seek proper medical help.