PNP switch is conducting
Even with the opto-coupler &quot;off&quot; there will be enough leakage current through the transistor to slightly turn on Q2.
There is a current path from the 50V, through the E-B junction of Q2 (basically a forward biassed diode), through R6 and through the opto which might be officially &quot;off&quot; but will still pass a bit of leakage current. That tiny bit of current passes through Q2 base and is amplified by its hfe. The current has nowhere else to go, and you probably have 0.55 or 0.6V Vbe on Q2 because of this - Q2 is &quot;just about on&quot;.
It depends a bit on what range of voltage you expect your &quot;50/60V&quot; to be, but you need to ensure that the opto needs to be properly on before Vbe of Q2 gets to 0.6V or so. A resistor in the emitter of Q2 helps, but better would be a shunt resistor (about 470R should do it) from Q2 base to the 50V in.
This still allows Q2 to saturate on when the opto is on (0.47/20.47 * 50V = 1.1V, plenty to turn it on), but will shunt away the leakage current of the opto from Q2 base when it is off.
(Note however that that value likely won't alleviate the problem with 12V in, so you might have to tweak this approach to fit your expected range of input volts.)