It sounds more like the charger is going bad. It is extremely common for them to not charge while the device is on, and only when it is off, when the charger is starting to go. It is because they are not putting out enough power to both run it and charge the battery. So I would start there and replace the charger.
Have you checked the settings in "Control Panel" and "Power Options", then go to "Change plan settings" and then to "Change advanced power settings". Check the options in there (not just for the battery, but in the other sections as well) and make sure nothing is set to keep it from charging while on.