When an electric dipole is placed in an electric field E,
a torque τ=p×E acts on it.
This torque tries to rotated the dipole through an angle θ.
If the dipole is rotated from an angle θ1 to θ2,
then work done by external force is given by W=pE(cosθ1−cosθ2)
Putting θ1=0∘,θ2=90∘
in the Eq. (i), we get W=pE(cos90∘−cos90∘) =pE(1−0) =pE