Punishment of the one who leaves Islaam
Praise be to Allaah.
The punishment for apostasy (riddah) is well-known in Islaamic Sharee’ah. The one who leaves Islaam will be asked to repent by the Sharee’ah judge in an Islaamic country; if he does not repent and come back to the true religion, he will be killed as a kaafir and apostate, because of the command of the Prophet (peace and blessings of Allaah be upon him): "Whoever changes his religion, kill him." (Reported by al-Bukhaari, 3017).
It is well-known in Sharee’ah that the punishments (hudood) are not carried out on minors, because they have not yet reached the age of responsibility; but in the case of those who have reached the age of responsibility, the punishment (hadd) applies, without a doubt.
The person who knows the truth and believes in it, then turns his back on it, does not deserve to live. The punishment for apostasy is prescribed for the protection of the religion and as a deterrent to anyone who is thinking of leaving Islaam. There is no doubt that such a serious crime must be met with an equally weighty punishment. If the kuffaar do not give people the freedom to cross a red light, how can we give freedom to people to leave Islaam and disbelieve in Allaah when they want to?
It seems that the intention of the teacher mentioned in the question was to shock the students with news of this ruling, in order to mislead them from the way of Allaah. You must respond and explain to him and the other students as much as you can.
May Allaah make you and us bearers of His Message and defenders of His Sharee’ah.