All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
The self is a deposit with the person, so he must treat it in a good way and not harm himself without a preponderant benefit.
The Prophet said: "There should be no harm nor reciprocal harm." [Ibn Maajah]
However, if there is a preponderant benefit, then this becomes permissible, such as circumcision, for example.
Circumcision involves some harm, but it is permissible due to its benefit. Or like a female piercing her ear in order to adorn herself with earrings. Since this includes a preponderant benefit, which is adorning herself, then it became permissible. But in principle, it is forbidden to harm oneself.
Allah knows best.