This question admits of more than one answer.
If you are unfair, or do harm to someone just because you don't like them (the teacher example), you can be "morally evil", "unjust", "foul", "spiteful", or a dozen synonyms depending on what you've done.
If you don't like the person because of a minor incident, you are the kind of person who nurses a grievance or holds a grudge (as already mentioned by Tushar).
But for something more serious, and you want to get even, I would say it's revenge. And you may be a revengeful person.
evil (adj) morally bad, causing harm or injury to someone MW
revengeful - (adj) "full of or prone to revenge" MW
grievance - (noun) " a feeling of resentment or injustice at having been unfairly treated" e.g. In the petition, the students listed their many grievances against the university administration. TFD
get even (verb) informal, "if you get even with someone who has done something bad to you, you do something bad to them" TFD
grudge - (noun) " A persistent feeling of ill will or resentment resulting from a past insult or injury" e.g. She held a grudge against her former boss. ODO