I can understand the distress you are through. Firstly, masturbation has no relation to concentration ability. Masturbating cannot increase the ability to concentrate. Not able to concentrate can be a symptom of underlying anxiety problem. Compulsive masturbation is also likely as it is commonly associated with anxiety. A detailed evaluation of the complaint is needed. Also the masturbation pattern must be explored in detail.
Next Steps
Considering a need for detailed interview, I would suggest you to consult with a psychiatrist.
Health Tips
With suitable medications and treatment it can be improved. Don't worry.