"Where is a teacher?"
Translation:Ubi est magister?
Magister is part of the o-declension. The endings define which case the noun is. In this certain sentence, we need the Nominative singular (since we only ask for one teacher, not several).
Magistrum would be accusative singular.
https://en.wikipedia.org/wiki/Latin_grammar#Declensions here you can find all declension in Latin.