As we know that electrostatic force is a conservative force
so we can say by the condition of conservative force

here we can rearrange the above equation as

now integrate both sides

Now we know by the definition of work done by a force is given by

now work done by conservative force is given as

Now from above work done by electric field to move charge from one point to other is given as

so here work done is given as

so change in potential energy is given by work done