I was thinking possibly an optoisolator, but it sounds like those put out a voltage,
No they don't.
You can get all sorts of components optically isolated, like a triac, transister, SCR, logic gate or FET.
For your case an opto isolated FET would fit the bill very well.