I've suffered with these for about 8-9 years. Don't freak out, but you really ought to get these checked out, by which I mean get your GP to refer you to a neurologist. This is because postcoital headache can be a symptom of some things like subarachnoid haemorrhage. It's VERY, VERY unlikely, but they are very, very serious so you can't ignore this. Once they've been ruled out, and if the headaches keep happening after sex, you'll be left with a diagnosis of benign sexual headache. This is GOOD because you're not about to die or burst a blood vessel in your head, but BAD because you are having bad headaches when you orgasm. Some neurologists might tell you, as mine did, that it's 'not a serious problem.' They mean, it isn't life-threatening. But it IS serious: I asked mine, if he had a splitting headache, like all your toothaches coming at once, when he reached orgasm, would he regard that as serious, or not? And then I insisted on seeing someone else.
You say this is the first time you've experienced this, and you're having sex infrequently. Can I ask, was it the worst headache you've ever had? That's how sexual headaches usually start. Don't have any more orgasms, whether via sex or masturbation, until you've had a scan (I had CT and MRI). Assuming they don't show anything amiss, you then have to consider how to go forward. If you find that you can have orgasms without headache, great. If not, try to pin down if there's anything you're doing to bring the headaches on. Holding your breath, tensing up, posture are all quoted as being possible causes. Take a look at the Naked Scientists forum: www.thenakedscientists.com/forum/index.php?topic=2734.0 for other people's stories and a range of things to try.
If the headaches continue, you have my every sympathy; this is an embuggerance. But your sex life is NOT over. They sometimes spontaneously go away. Painkillers, taken before sex, can help. And you can learn how to minimise the chances of them happening. I find that if I don't try to have too many orgasms, that helps more than any other single thing. Once a week is an absolute maximum; once a fortnight is much better because sex - or masturbation -is much less forced, much more natural, you're turned on more. I've had these for years, and for a while I thought my sex life was at an end, but I now have at least 50% pain-free orgasms, and sometimes much better than that. Best of luck; DM me if you want.