Cramps during sex

So the last time I had sex I got awful cramps and couldn’t finish. I wasn’t near my period either. I had just gotten my IUD placed could that effect it?? Please help