I see that Telaclavo has given you a good answer for a bipolar transistor. Here is what it would look like with the right kind of FET:
For low voltages like 12 V, FETs are available that turn on well enough with only 5V or even 3.3V on the gate. These are sometimes called logic level FETs. The gate can then be driven directly from a CMOS digital output.
The diode is essential to not damage the FET. A motor will look inductive, so when you attempt to switch it off it will raise its voltage to whatever it takes to maintain the current until the resulting reverse voltage eventually causes the current to go to 0. This is sometimes called inductive kickback. Without the diode, that kickback current has no place to go and would raise the FET drain to a high voltage so that the FET eventually breaks down and thereby allows the current to flow. This is not good for the FET. A Schottky diode is a good idea here since they are fast, and at your low voltage they are readily available for suitable characteristics.