23 weeks and painful orgasm

I am 23 weeks pregnant with my third baby and every time I have sex and orgasm I get contraction feeling pain where I have to tuck my legs into my chest. Has anyone had this if so what did your dr say about it?