Why does it still hurt?

I recently just started having sex about four months ago. It always starts out good but after a while it hurts so much that we have to stop. We have only had sex with each other so we are still learning. Does anyone else have this problem? Or have any tips.