Try a different charger, or a different cable or usb port.
If it still won't charge, even when switched off (so it's nothing to do with the android software) then it would seem to be the phone hardware, in which case a repair is the answer (but check that there's no dirt blocking the contacts first). The only other thing to try would be a different battery.
If you are lucky it will just be the charger though.