(a) Sought work is equivalent to the work performed against the electric field created by one plate, holding at rest and to bring the other plate away. Therefore the required work,
$$A_{agent} = qE (x_{2} - x_{1})$$,
where $$E = \dfrac {\sigma}{2\epsilon_{0}}$$ is the intensity of the field created by one plate at the location of other.
So, $$A_{agent} = q\dfrac {\sigma}{2\epsilon_{0}} (x_{2} - x_{1}) = \dfrac {q^{2}}{2\epsilon_{0}S} (x_{2} - x_{1})$$
Alternate : $$A_{ext} = \triangle U$$ (as field is potential)
$$= \dfrac {q^{2}}{2\epsilon_{0}S} x_{2} - \dfrac {q^{2}}{2\epsilon_{0}S} x = \dfrac {q^{2}}{2\epsilon_{0}S} (x_{2} - x_{1})$$
(b) When voltage is kept const., the force acing on each plate of capacitor will depend on the distance between the plates.
So, elementary work done by agent, in its displacement over a distance $$dx$$, relative to the other,
$$dA = -F_{x} dx$$
But, $$F_{x} = -\left (\dfrac {\sigma(x)}{2\epsilon_{0}}\right )S \sigma (x)$$ and $$\sigma(x) = \dfrac {\epsilon_{0}V}{x}$$
Hence, $$A = \int dA = \int_{x_{1}}^{x_{2}} \dfrac {1}{2} \epsilon_{0} \dfrac {SV^{2}}{x^{2}} dx = \dfrac {\epsilon_{0}SV^{2}}{2} \left [\dfrac {1}{x_{1}} - \dfrac {1}{x_{2}}\right ]$$
Alternate : From energy Conservation,
$$U_{f} - U_{i} = A_{cell} + A_{agent}$$
or $$\dfrac {1}{2} \dfrac {\epsilon_{0}S}{x_{2}} V^{2} - \dfrac {1}{2} \dfrac {\epsilon_{0}S}{x_{1}} V^{2} = \left [\dfrac {\epsilon_{0}S}{x_{2}} - \dfrac {\epsilon_{0}S}{x_{1}}\right ]V^{2} + A_{agent}$$
(as $$A_{cell} = (q_{f} - q_{i}) V = (C_{f} - C_{i})V^{2})$$
So $$A_{agent} = \dfrac {\epsilon_{0}SV^{2}{2} \left [\dfrac {!}{x_{1}} - \dfrac {1}{x_{2}}\right ]$$.