Converting 5 volts to 12 volts using a photocoupler
Your diagram doesn't show any of the part specs, but consider the transistor as a perfect on-off switch.  If it is open circuit, then the output terminal is simply connected to the +12 through the 4.7Kohm resistor, and can source 12V/4700ohm=2.5mA of current.  When the transistor is closed, it will sink the 2.5mA and whatever else it is capable of.

If your relay needs more than 2.5mA, you could need a smaller pullup, but you don't want to overload the transistor's capacity.  If you need more than the optoisolator can handle, add a transistor or mosfet to the output.