The very popular from of potential energy of the dipole is $-P.E$. But in the derivation of it, we have negelected the potential energy of the pair of charges constituting the dipole. will this not affect further treatment when we try to apply this to understand aligning of molecular dipoles in electric field? If yes, then how will the modified potential energy function look like?
When we talk of a dipole, we usually assume that its configuration is fixed or the changes to the configuration are negligible.
So the effect of an external field on changing the length between a pair of charges is not considered when we are taking them to be a dipole (usually we consider the charges to be rigidly bound).
As mentioned in the answer by @Manishearth the potential energy of the dipole is not considered in simple considerations of the dipole. However, such considerations can't be neglected in the study of wave propagation and specific heat of the substance. You might remember even from the elementary study of specific heats in high school that at high temperatures the vibrations mode become significant. Those are the effects that arise when we consider the energy between the charged particles of dipoles up to harmonic approximation. In the study of waves, this gives rise to the optical modes (https://en.wikipedia.org/wiki/Phonon#Acoustic_and_optical_phonons), when talking about dissimilar particles