When a capacitor is charged, work is done by the charging battery. As the capacitor charges, the potential difference across its plates rises.
The total amount of work in charging the capacitor is stored up in the capacitor, in the form of electric potential energy between the plates.