Let's start with saying that your source schematic needs to be ignored when it comes to good practise. Just so you know not to try and learn much from it.
They have the MCU connected directly to a transistor's base, with no resistor, which is already bad form, even if you know that 99 out of 100 cases it'll probably be fine.
But to then add an opto-coupler on the other side in the return path is nonsense, your domains are already coupled through that first PNP transtsistor, opto-coupling is a waste of space and money, since just a transistor stage, or nothing at all, would do the same trick.
Then, there's no drawn-in pull-down resistor on the opto-coupler output, so it will not, in fact, "go low", because it can't.
Add to that, the load is switched by a PNP transistor, where the load is in the emitter-path of the transistor, so this will never work properly, since the transistor and the load will balance out at some point, probably about 3V to 4V for the load. And as such, in a similar manner, whether that "charge indicator" will be properly triggered enough to make an LED light up is severely questionable.
It may work for a 100mA load using an opto-coupler, because they only need about 1.1V, but still then is it a bad design.
Basically the entire schematic needs to be re-thought and I, for one, am too hungry and tired to do that right this second. Maybe later.
Edit: Sod it, I'll add a schematic....
simulate this circuit – Schematic created using CircuitLab
The comperator senses the voltage across the pass MOSFET, if the voltage on its negative terminal goes a certain amount of milivolts below its positive the output will enable high (some, or most, Comperators need an external pull-up resistor though).
The pass MOSFET is a P-type in the VCC path, because switching the ground is stupid, because a lot of stuff can connect grounds together (power-ground, audio-ground, etc) and usually VCC is just used per device. So you always switch on and off the VCC, not the ground.
To buffer the MOSFET an NPN transistor is added, so you can drive it with any voltage, 3.3V or, what you like, but if your controller runs on 5V, you can even leave it out, but then the MCU will have to output low to enable the MOSFET.
Once a MOSFET turns on it will present a little bit of resistance, if you select one with about 0.1 Ohm to 0.2 Ohm on-resistance ( Rds[on] ) that allows a small voltage to drop across it when it's on, but not enough to really hinder your charging. When in doubt, make the supply 5.2V to compensate.
Make sure your MOSFET is specced for logic levels and that your comperator has an offset voltage around 50mV. 50mV offset/hysteresis in the Comperator will be about 500mA with a 0.1 Ohm MOSFET, or 250mA with a 0.2 Ohm MOSFET. So the MOSFET's Rds[on] and the Comperator's offset voltage together will determine at what current the Comperator's output turns on.
R4 may be skipped, or increased in value, to reduce "turned-off" leakage, but the detection of "something is no longer present" will take a bit longer, especially if the MOSFET is a relatively high quality. (Very high off-resistance)
For more in-depth, I am seriously too tired right now.