Masturbation is self-pleasuring. Religious authorities, however, call this self-abuse and have done so for centuries. Responses to masturbation change with the times. It is not a crime - however, masturbating in public is usually not considered acceptable and may attract sanctions from public society and cultural norms.
It is also considered a sin by some religious groups and preachers, but this depends on the specific religion. However, a quick [google search] brings up many arguments why masturbation need not be considered a sin in Judaism or Christianity. In Islam, masturbation is usually considered a sin, though there may be some exceptions when it is not - see wikipedia:Islam and masturbation for a more thorough discussion if this concerns you.
Compulsive masturbation, like all other compulsive behaviours, is a sign of an emotional problem and needs to be addressed by a mental health specialist. It is better to address compulsive behaviour than try to repress it, where it may emerge or cause other problems, such as psycho-sexual dysfunction.