This is primarily wrong because of the relationship between student and teacher, which can lead to grade inflation, cheating, etc. Its a dual relationship, and something that should be avoided, especially in the school systems.
Other than that, the moral dilemma is a whole other story, i.e., whether its okay for a 16/17 year old to have sex with someone who is above 18.