For simple on and off you would use single transistor with a diode anti-parallel with the magnet coil. The transistor switches the magnet on, the diode bypasses the inductive spike that occurs when the transistor turns off.
If you need faster off times you would need two transistors in a totem pole configuration, so that the second transistor could dump the coil current to ground causing the magnetic field to collapse faster (the diode will allow the current to go through the coil until it dissipates from the ohmic resistance of the coil)
If you need to reverse the current through the coil you need four transistors in an h-bridge configuration. Schematics for everything I've described are easily found searching Google for a few minutes.