Sex may be painful for a number of reasons, either because it is an experience the body is not used to, perhaps the person is tense and unable to relax, perhaps there is not enough lubrication being used or because there is something that needs a doctor’s advice, e.g. sexually transmitted infection.
Some people have sex even though it hurts because they understand it might hurt to start off with, but they want to have sex anyway because they think it will get better.
If done with the right person at the right time, sex can be a great thing. It can sometimes come with discomfort and pain so it is important to make sure that changes are made to stop that pain or discomfort so that both people are happy and comfortable. If one person wants to stop having sex then the other person must stop.