I agree, I think you should see your doctor about this. There are a lot of things that could be causing this problem for you.
If it is your heart causing the syncope, *usually* the first suspicions are a slowed down heart rate (bradycardia < 60 beats per minute) and/or blood pressure goes too low. This can happen for many different reasons.
Keep in mind I’m speculating here….It could be a vagal response, i.e. sympathetic nervous system not responding as it should. It could be a conditioned vagal response, meaning you are consciously or sub-consciously afraid of this happening so---it happens. Could be a blood sugar drop during sex.
Your best bet is to talk to your doctor though. If you really want to get it resolved I think it will take medical attention, IMHO.