If you look at How Electric Motors Work, you will see that the field magnet and the rotor magnet attract and repel one another at different points in the cycle.
The commutator is in charge of flipping the rotor's magnetic field. The direction of rotation therefore depends on which way the current is flowing through the rotor. If the motor is driven by a battery and you flip the polarity of the battery, the direction will reverse.
Here are some interesting links: