Uncomfortable pain during sex

Every now and again when me and my gf is having sex i get this pain in my grind in the middle of sex, sometimes it hurts so much that I have to stop having sex and relax my body to recover from the pain, its been happening for a few months now, it don't happen all the time when I am having sex but it happens every now and again... Can someone please give me any advise on what may cause the pain?