I think you understand how to drive a 24V output with a 5V signal - use an NPN transistor as a low side driver. But I'll stick a picture in anyway. R1 should limit your current to something small - I'd use 4.7K to limit it to ~1mA. R2 should be large - 100K or so, not critical. It prevents startup glitches on the output. It wasn't clear if you wanted to drive differential 24V (-24vand +24V).
**broken link removed**
I would not support programmatic switching of the output voltage as it is very easy to inadvertently fry something. The above circuit will support both 24V and 5V, just supply both outputs as shown in the second picture.
**broken link removed**
In both cases, you will want to treat the collector terminal as ground. Note, if you want to drive relays, you should put a reversed diode across the outputs (2 diodes for the second picture.
If you insist on programmatic switching of the output voltage, you can use PNP drivers on the high side to switch between +5 and +24 which feeds the voltage terminal of your output.
What i didn't understand is your comments about differential driving. Do you mean driving so that the two output terminals switch polarity? You will need an H-Bridge for that.