It really couldn't do any harm to visit a doctor.
The pain could be caused by something simple like needing more lubrication or foreplay, or it could be caused by a something that requires medical treatment.
Are you on birth control? I was on one pill that killed my sex drive and made sex uncomfortable.
Are you able to masturbate comfortably with penetrative toys or does the pain only occur during partner sex?