Optocouplers sound like a good solution but you have to know the way the current flows. Also by nature they will cause a voltage drop across them (about 0.3-0.5V typically) and they're directional so won't switch an AC signal. Another option is a set of small relays.
Optocouplers will usually work, whether they do depends on the rest of the circuit.
Mechanical relays will always work but are bigger/costlier.