You can follow the recipe at http://mbed.org/cookbook/Motor which uses the
Motor interface for driving a standard DC motor with PWM and an H-Bridge.
If, instead of using the L293D dual H bridge driver, you want to use a transistor to drive the motor. You choose the transistor mainly by looking for a switching transistor which has a current and voltage rating that exceed the current and voltage ratings of the motor (so it depends on the motor) - for high currents you may need a heatsink for the transistor.
For a bipolar junction transistor (BJT) you'll need a resistor to limit base current. Most driver circuits incorporate a diode to prevent harm to the transistor from back-EMF from the motor windings.
The connections to a BJT are base, emitter, and collector
You can find out which leg is which by looking at the data sheet for the specific transistor you have chosen. For example
You can instead use a MOSFET, these can be more efficient (lower voltage drop when 'on')
Some rather good instructions can be found here