Sorry for not explaining earlier. Yes its an PWM to analog converter. The intent is to get 0V and 10Vat 'PWM_OUT' for 0% and 100% duty cycle respectively. R13/R14 have been reduced to 470ohms and R11 has been replaced by 0 ohms.
Anyways, thanks for the analysis. The BS250 part was faulty causing unexpected results. After replacing it and also doing the resistor changes mentioned above, the circuit works fine.
Well the optocoupler will be pretty slow with that 4k7 pullup on the output, why not just use a MOSFET
driver chip to level shift up, fast as you could ever want, one chip, simple (well you need the RC
filter on the output and a decoupling cap too). Much simpler solution, and can drive very low impedances
too if wanted.