(mini & micro) USB connectors have 5 pins: Vbus, D-, D+, Id, Gnd.
For OTG, the Id pin is connected to Gnd.
It's like the old adage, "You can lead a horse to water, but you can't make him drink."
You can connect a peripheral to an OTG host and have it work fine.
You can then connect an external power supply across the Vbus and Gnd.
The problem is, how does your host device know that it can "drink"?
There are basically two ways.
If the host detects power on its input before it switches into OTG host mode it may continue to charge.
If the host is in OTG host mode, device-specific commands to the charging circuits may convince it to charge.
There may also be non-standard Id resistor values for signalling host & charge for some devices.