Potential energy of dipole is the energy possessed by the dipole by virtue of its particular position in the electric field.
Total work done in rotating the dipole from orientation θ1 and θ2 is stored in the form of potential energy and is given by :-
W = -pE (cosθ2 - cosθ1)
Where θ1 is the angle at which dipole is in stable equilibrium = 00
and θ2 is the angle at which dipole is in unstable equilibrium = 1800
Hence, work done , W = 2pE .