Two circuits with different voltages - should I use a transistor or an optocoupler as a switch
If the two circuits need to be isolated, then an optocoupler, relay, or optical relay would be preferable. This should prevent ground loops or other dangerous interactions.

A relay may require more current than the gpio can supply, but then again I haven't used them as often as opto's.