This is a quite current hungry as the opto LED will take a few mA to make it light. The level of difficulty depends on what you are driving and how much protection you need.
From your circuit it looks like you are just driving a logic output at slow speed.
A simple series resistor is a good start, using the diodes to the supplies from the pin in the micro to do the rest. The resistor limits fault current into these diodes (max diode current is shown on the micro-controller data sheet).
The next stage is series resistor followed by a TVS (transient voltage suppressor) diode to 0V and then another resistor to the connector. This will help protect against ESD. Remember that the ESD current will go somewhere, so make sure that it can get to ground without going through your circuitry.
The first resistor protects the micro's diodes because the TVS voltage can rise significantly above its breakdown voltage during a fault. The second resistor to the external connector protects the TVS. The values and power rating of the resistors depends on what Voltage your user can wire the output to!
Most TVS specify power handling for very narrow pulses, so it will be much much less for a continuous connection.