When charging a capacitor transferring charge from one surface to the other, the first surface becomes negatively charged while the second surface becomes positively charged. As you transfer the charge, the voltage of the positively charged surface increases and the energy stored in the capacitor also increases. We can solve this by the definition of capacitance that is a measure of the ability of a capacitor to store energy. For any capacitor, the capacitance is a constant defined as:
[tex]C=\frac{Q}{V_{ab}}[/tex]
To maintain [tex]C[/tex] constant, if Q increases V also increases.
On the other hand, the potential energy [tex]U[/tex] can be expressed as:
[tex]U=\frac{Q^{2}}{2C}[/tex]
In conclusion, as Q increases the potential energy also increases.