Assume I have a closed system of a stationary proton and a photon with sufficient energy for electron pair production to take place (say, $1.122\,\mathrm{MeV}$), where all the laws of physics apply.
Taking the rest energy of a proton to be $938.272\,\mathrm{MeV}$, the total energy of this system is $939.394\,\mathrm{MeV}$.
Now, when my photon undergoes pair production, I have an electron-positron pair with a combined K.E. of $0.1\,\mathrm{MeV}$ and a proton. The total energy is still the same as before.
However, the proton and electron attract each other, thus increasing the kinetic energy of both particles and the system as a whole. Supposing that the collision between the two particles is elastic, the energy of the system has now increased permanently.
When two charged particles attract or repel each other, the gain in kinetic energy is a result of the loss of potential energy. In this case, however, the photon didn't have any potential energy.
So where does this energy come from?