There's no wrong time to write a thank-you card for a teacher, but it's customary to write a note around the holidays, at the end of the year, when they retire or during Teacher Appreciation Week.
You can send a free e-card with a personalised message on the Thank a Teacher website to anyone who works in your school. So, if you have a really special teacher, teaching assistant, playground ...