The believer who is keen to save himself will strive to save himself from everything that may lead to his doom, and he is kind to himself. Part of that kindness is taking care of one’s relationship with Allaah so that he will be saved from the punishment of the Hereafter, and striving to make himself do that which is enjoined upon him and to avoid that which is forbidden to him, seeking thereby the pleasure of Allaah. So he starts by repenting from all sins, and urging himself to compete in doing righteous deeds, and striving to reach high levels of faith, by applying the appropriate means, such as learning about the rewards for good deeds, the effects and causes of sin, keeping away from those who discourage him and are lacking in ambition, listening to stories of those who strive in worship. Then if he weakens in doing righteous deeds or commits sin, or finds that he is inclined towards it, this is the time for punishment.
Punishment comes after learning the truth and deviating from it. You should not start with punishment because there is no punishment before knowledge and knowledge leaves no excuse.
You should also note – may Allaah bless you – that punishment should not be sought as an end in and of itself, rather it is a means of disciplining the self. This is like cauterization for one who is sick, which is only used as much as is necessary.
It is not good to punish yourself and burden yourself with more than you can bear, or with things that cause physical harm, such as burning yourself with fire or standing in the sun, etc. Rather punishment should take the form of obliging yourself to do more righteous deeds, without causing too much hardship, or depriving yourself of things that you like. However, you know yourself best and you know what makes you more lazy and pushes you towards sin, and you should avoid these things.
Al-Maqdisi (may Allaah have mercy on him) said:
If the believer checks himself and sees some shortcoming or he commits some sin, he should not take the matter lightly, for that may lead to him committing sin regularly and then it will be difficult for him to give up that sin. Rather he should punish himself in a permissible manner just as he would discipline his wife and children. It was narrated that ‘Umar went out to a garden he owned, then he came back and the people had prayed ‘Asr, so he said, “I went out to my garden and when I came back the people had prayed ‘Asr; I give my garden in charity for the poor.”
And it was narrated that Tameem al-Daari (may Allaah be pleased with him) slept one night and did not get up to pray Tahajjud (late night prayer)until dawn came, so he prayed qiyaam al-layl (voluntary night prayers) for a year and did not sleep in order to punish himself for sleeping that night.
Hassaan ibn Sinaan passed by a room and said, “When was this built?” Then he thought to himself and said, “Are you asking about something that is not your concern? I will punish myself by fasting for a year,” and he fasted that year.
But with regard to punishments that cause physical harm or involve doing something reprehensible, they are not permissible. It was narrated that a man looked at a woman, then he put his eyes out, and that another disobeyed Allaah with his hand, so he put his hand into the fire until it became paralyzed. Such actions are not permissible, and a man cannot treat himself in this way.
From Mukhtasar Manhaaj al-Qaasideen.
And Allaah knows best.