My son (nearly 4) also hurts himself when he is upset. He often hits himself on the head, bangs his head on the floor, or bends his fingers very far back. For us, this is part of a bigger issue about throwing temper tantrums and controlling his emotions.
We are working with a behavioral therapist about this. He also goes to OT. My son is pretty verbal and can articulate when he is upset, sad, angry, etc. But in the moment, he gets very overwhelmed and seems to have a very difficult time not throwing tantrums. The bending his fingers back appears to be his attempt at doing something less demonstratively self-injurious than the hitting and banging, but it's just as upsetting when we see it.
What is starting to help with the tantrums (and thus the self-injury) is a combination of stern discipline and more positive discipline. We prep him a lot for situations that have traditionally been problematic (mostly playdates), give him alternate scenarios for how he can deal with difficult situations (tell him to count until he feels calmer, walk/run away from a kid that is getting too close, ask for help), things like that. But I also make sure there is a consequence (punishment) when he has a tantrum so that he knows that he is not behaving in an acceptable manner. He understands it all cognitively. It's more a matter of putting it into practice. He has had some very good days lately, but he has also told me that it was hard for him to keep his temper. I'm hoping it will get easier for him the more he does it.
Good luck. It is so awful to see your little one hurt himself. If our behavioral therapist comes up with any other suggestions that work for us, I will let you know.