Only charges through USB when screen is locked
The most likely cause is that your PC can't supply enough current over the USB connection to charge your phone while it's awake. Smartphones draw a lot of power these days, so their chargers use extensions to the USB standard to supply more power, so they can charge even while the phone is in use. Most PCs don't support these extensions, so they can't.

The solution is to use the charger to charge your phone. You can buy a Y-shaped USB cable which splits the power and data connections, so you can have it plugged into the PC and charger at once if need be. Some docking stations also have this ability.