A former teacher who had a sexual relationship with a pupil has been banned from the profession 17 years after his school said it raised concerns.