Is retaliating to threats classed as self defense?
Retaliating for anything is not self defense. Even if the guy was hitting you two seconds ago and the guy stopped it would no longer be self defense to hit him, I would be mutual combat. Self defense is stopping a person from doing you harm when they are actually doing something (like hitting) to you. Once they have stopped, lets say because you knocked them down, it is no longer self defense if you continue to hit then.
Retaliation is not self defense. Hitting someone in anger/frustration is not self defense. Self defense is only applicable in situations where you have a genuine (and reasonable) fear of immanent harm and your only option is to physically defend yourself. It also doesn’t apply if you instigate the confrontation (meaning, if you do things to get him worked up so that he’ll take a swing at you).
I’m going on the assumption that this is something that is happening in school. First, get a teacher or principal, someone in position of authority, and let them know about it. It is their responsibility to look out for the safety and well-being of all students. See if there was anyone else around you when he made those threats that you can count on as witnesses. As far as your question goes, from what you’ve said I don’t believe you’d get off scott-free. He’d actually have to make a swing at you before you would have the right to retaliate (and even then, unless he’s actually hurt you a couple of times before you fought back, you might be disciplined for an excessive response). The only time you’d have a legitimate defense for physically attacking him first was if you could prove that you legitimately feared for your life.