If there is any difference,
The math teacher means that the teacher's major is math. But he doesn't necessarily teach math. For example, he may teach physics.
The math teacher is the teacher who teaches math classes, and the major is not necessarily math. For example, he studies physics, or he may teach math.