Self-punishment can be beneficial if used the right way. For instance, if you receive a low test score in school, you could punish yourself by not going out with friends until you retake the test and get a better score. This would be beneficial because you would then know the material covered better and by doing so, would improve your grades. On the other hand, I do not believe that physical self-punishment is beneficial.
It is important to have self-discipline in order to achieve success. You should set goals for yourself and if you fail to reach them you should be hard on yourself and punish yourself for not reaching them. This is the only way to get better and ultimately be successful in the end.
I used to be a slacker. To encourage myself to do better I started applying rewards and punishments to myself and it does work. Don't punish yourself in any way that would compromise your health and never hate yourself, always love yourself, apply the punishment to yourself like a loving parent would. For example I may deny myself some of my favorite things if I have not met my self-imposed goals. I may decide that if I don't get X done satisfactorily I will impose no television on myself or I will put favorite foods or activities off limits for a time. Why not just choose to meet them? Because I'm human and have a subconscious, emotions, weaknesses like anybody else. So I forgive myself for my tresspasses against my self and my goals but I also hold myself accountable for them.
When people hurt themselves on purpose, it's a cop out against creative thinking. They believe that sunk costs of pain = opportunity costs of achievement. Just because people try hard doesn't mean they're trying smart. In order to improve, one has to QUALIFY efforts constructively, NOT simply QUANTIFY efforts out there.