How can masochism be stopped?

First, an evaluation. Hi, as suggested, start with a psychiatric evaluation. This is a challenging problem, and treatment typically involves a combination of medications and psychotherapy. Cognitive behavior and reconditioning therapies are commonly used. In my experience, psychodynamic approaches can be effective as the focus is on working through the underlying causes of the behavior. Hope this Best wishes.
Tough question. Talk to your psychiairist. In nyc everybody has at least two psychiatrists for a second opinion.