LG Ultrafine 4K display - USB hub turns off when screen turns off / unplugged from MacBook
This is expected behavior.  According the LG specifications the maximum power supplied when in sleep mode is 1.2W and when off is .5W. (This is for the monitor as a whole, not just the USB ports. For this answer, let's assume all of the power is being redirected to the ports - for illustrative purposes only)

Using the formula for watts and converting to solve for Amps,

W = V * A  =&gt; A = W ÷ V


So, assuming that the 5V remains constant, the amps it's supplying is .24A in sleep and .1A off.  For the record, that's not enough to charge a Nokia 3310 from 2000 much less a smartphone from the last 10 years.  

The power requirement for USB 2.0 is to supply upto 500mA (.5A), 3A for USB 3.1 and up to 5A for power delivery (the type C interface).

When you unplug your MacBook from the monitor, it goes into sleep mode and dropping power consumption which ultimately disconnects your devices.

My solution is to purchase an Anker USB charging hub that's designed for this type of task. I've purchased this exact charging hub and positioned it at the side of my desk to charge the myriad of devices.  Even when I need to connect my device to my Mac and charge simultaneously, I have a hub that's capable of delivering 10W on the port.