High school, NO. It would be highly inappropriate. Not to mention most students are underage.
College, possibly on certain conditions. One, the student is not fresh out of high school, but is an older adult that has returned to further their education and career. There are people going back in their thirties and forties for various reasons from getting the education they never had to obtaining their masters to updating their skills.
The other condition would be that the student would not be taking any of the teacher's classes in the future, or have already completed their classes. Preferably waiting until after the student graduates. Then again there is nothing to stop favoritism if a teacher likes a student. If you have seen it, think of the film Back to School with Rodney Dangerfield.
I know in the college I went to the head of the department was dating a young student, and eventually lost his job. It got bad when you walked in his office, and the student was sitting on his lap. I don't know, it may have been more because of inappropriate behavior than just dating a young student. Maybe he did it one too many times. Even college teachers can get into trouble on that aspect.