I cannot tell you how many texts and emails I get from students that start with either nothing or with the word "Hey." I think sometimes students don't know what to call their teacher.
I've even had students come to me from another teacher who couldn't remember the name of their previous teacher! I can't imagine how my students would feel if I didn't know any of their names. Knowing someone's name and using it strengthens our personal connection. It also is a sign of respect.
Go by the most formal title you can think of for that person. Mr., Ms., or Mrs. are good places to start. If your teacher doesn't like that formality, he or she will let you know. In college, Doctor or Professor are important titles to use where appropriate although some faculty go by Mr. or Mrs. (ask around, look them up, find it out). Always defer to the most formal title that fits unless told otherwise.
Another way to figure this out is to just...ask!
It's easy-peasy, lemon-squeezy. Just be sure to call your teacher something by way of greeting, especially when texting or emailing. It's the polite thing to do!