part of his punishment is not knowing who he is until the end
Here's what I think is going on.
The entire movie takes place in Hell. We the viewer are never not in Hell. The killer's punishment is not just to experience what he did to the girl, it's to experience it AS the girl, meaning specifically to experience the fear of not knowing what's happening to him in the same way that she did.
At the end of the movie, the mother says something about how she hopes he finds out what it's like to die in terror and confusion, and that's the movie telling us why he didn't know who he was until the end.
That final moment when he realizes why this is happening to him is the real punishment. As the girl, he's been running in fear and being tortured, and he experiences all of that suffering and confusion and unfairness, only to finally see that he's doing it to himself and that this is exactly who he is and what he deserves. He realizes that this is going to keep happening to him again and again. Then he dies as her and the whole thing resets itself, and that will continue to happen to him for eternity.