Pain while having sex

My boyfriend and I don’t have sex that much but when we do it hurt. I felt a big discomfort. In the past I had sex a lot and it didn’t hurt that much but when I take some time off and then have sex again why does it hurt like I’m a virgin all over again?