Equation for work done in rotating dipole from angle 'X1' to angle 'X2'
Work done = P * E (cos X1 - cos X2)
Here, cos X1 = cos0 = 1 (stable)
cos X2 = cos 180 = -1 (unstable)
So,
Work done = P * E (1--1)
= 2PE
=====
Since P and E are positive, work done is positive. So Energy is consumed.