To be honest, and this is after reading most of the comments here and drawing my own conclusion, I feel like a mix of things is my answer;
Dark Force/Force Rage is my main. If you watch when he actually gets hit with it, his reaction is to then stand up and walk away; I feel like that moment is underrated, for him. The sheer strength that would take is immense- it would be a good deal easier if he was fuelled by dark force at that present moment in time? And the way he takes a moment to look up at the reactions of Rey and Finn, and he looks angry too, makes me think that the Dark Force theory is quite likely; the fact that you become especially drained after Dark Force wears off would also explain why towards the end he staggers around like a drunkard and can barely defend himself, he's definitely on the defensive more so than you'd expect him to be. My other reasoning is, when Rey says 'the force' and seems to clear her mind, becoming calm, Kylo seems to be the complete opposite. Rey seems to be using the light to fuel her, as after this point she basically just kicks his arse, and Kylo is being fuelled by the dark, which takes much more out of you. Combine this with the freezing cold, and the fact he's now been fighting for quite a while with a serious injury, and it makes sense that Rey would suddenly be able to beat him. He seems to be lagging a little before each time he does it, deliberately hurting himself more, to keep fuelling the Dark Force. Another reason could be the more you use the Dark Force/Force Rage, the less affected you are by the light/the darker you become and as we know, the light is plaguing him to the extent he thought -the scene earlier- could stop it (though whether this works or not remains to be seen)- his primary goals are to vanquish the light inside of him and become as powerful, if not more powerful than Darth Vader. I feel like using Dark Force like this would definitely help make this happen.
Although, I don't think Dark Force is the only reason. I think it's also to help remind viewers how important it is that he was injured, and that he's not fighting at full strength (or he'd have easily beaten Rey). And to foreshadow this injury will cost him later on. (Hence, he loses the fight)
Another reason is indeed the type of person he seems to be- he lashes out at everyone and everything whilst angry and frustrated, I think in this fight its apparent he is both. The wound, since it would be causing him pain, is likely what he chose to focus on, hitting himself to get the anger out, and also because he hates the fact he's even wounded, almost punishing himself for allowing it to happen.
It could also be a scare tactic towards Rey and Finn, they seem shocked and intimidated the first time we see him do it.
And lastly, it could indeed be a medical reason, to numb, or change the type of pain, which I have done before now too- personally, I find it's also somewhat instinctive- or to stop a muscle spasm or unresponsive/seized up muscles.
Most of this is just repeating what others said, admittedly, but here's my full take haha.