When the capacitors are connected in series, the equivalent capacitance is given by
Because the capacitors are connected in series, the same charge will go to each of them and it is equal to the total charge given by the battery.
Now,
Let the charge at each capacitor be q.
The work done by the battery (W) is given by