If the distance between the two charges is decreased then electrostatics potential energy of the system
If the charges are of the same type work is done against the repulsive force and potential energy increases and if they are of different type work is done by attractive force and potential energy decreases.