Relay / Solenoid IO Driver:

Best for high voltage system where isolation is necessary

Terry Allen Steen, EE of Marina Power says:

The easiest way I have found is to drive the LED half of an optoisolator. Connect the output side to the relay and its source. I use the H11G2 (just because I have them around).
          +-------+
PIC OUT---|       |--+--RELAY--+- High voltage
          |       |  |         |
          | H11G2 |  '--DIODE>-'
       ,--|       |--,
       |  |       |  |
      \|/ +-------+ \|/
      GND           GND

Paul B. Webster says:

And you *did* mean to put a resistor in series with the opto input, did you not? And the diode across the relay?

Also: