Well it could be a few things.
1. Your battery could need replacing.
2. Your cord could be damaged, although still functioning to run the laptop alone. This is very common. When a charger cord goes but only partially. It will power the device, but not power it and charge the battery at the same time. It will also usually charge the battery when the laptop is turned off (not hibernate or sleep, but off).
3. A combo of both things above. The battery needing replacing and the cord as well.