Energy in an electric field under a gauge transformation Consider a (test) charge located at $\vec{r}(t)$ in a static electric field with potential $V(\vec{r})$. The energy for this system is given by
$$E = \frac{1}{2} m \dot{\vec{r}}(t)^2 + q V(\vec{r}(t)).$$
(One could add in a magnetic field without altering this energy.) It is well known that the potential can be changed by a constant without altering the physics; we can fix this by choosing the potential at $\infty$ to be zero (let us assume that all fields decay as $r \to \infty$ for simplicity).
Under a gauge transformation, we have
$$
V \to V - \frac{\partial f}{\partial t}, \qquad \vec{A} \to \vec{A} + \nabla f.
$$
If I choose $f$ to be a function of time only, this is equivalent to modifying the potential at $\infty$ in a time-dependent manner, which essentially adds a time-variable offset to the energy expression above. If I choose $f$ to be a function of position only, then the electric potential is unchanged, and the expression for the energy remains unchanged.
My question is how to interpret the case where $f$ depends on both space and time? Under such a gauge transformation, the energy of the system becomes
$$
E = \frac{1}{2} m \dot{\vec{r}}(t)^2 + q V(\vec{r}(t)) - q \frac{\partial f}{\partial t}\bigg|_{\vec{r}(t)}.
$$
What is the interpretation of this term? Why is the energy not well-defined, up to a choice of reference point? While I'm ignoring the field created by the charge, I don't think I need to consider it explicitly to understand this. Certainly in the test charge limit, it should have no effect. Note that the energy in the background field is invariant under the gauge transformation, as it depends on integrals of E and B only. What am I missing?
Edit: I'm well aware that the Hamiltonian for such a system is not gauge invariant, though the equations of motion are. I'm trying to understand why energy is not a "good" quantity to describe this situation.
 A: The issue is that you're kind of combining incompatible elements of the electrostatic and electrodynamic contexts together.
If you want to work in a completely electrostatic context, then it's best to always work in Coulomb gauge, in which case the energy of a charged particle is given by your formula. But in that case you lose your gauge freedom, and can't legitimately make the time-dependent gauge transformation that you describe.
If you want to use the full freedom to perform gauge transformations, then you're implicitly using the fully dynamical conceptual framework - even in your specific system happens to be static, the mathematical possibility for it to be dynamical is built into the gauge-theory description. In that case, you need to be more careful about "energy." The full conserved quantity does contain contributions from the electromagnetic field. Even if you hold the EM fields fixed (as with a test charge), then for consistency you need to use either the Hamiltonian or Lagrangian formalisms, rather than just the simple (kinetic + potential energy) setup from elementary mechanics. The vector potential ${\bf A}$ appears explicitly in both the Hamiltonian and the Lagrangian for a charged particle in an external field, and under a gauge transformations it transforms in such a way as to leave the equations of motion invariant.
As for the physical interpretation - well, it's notoriously murky. I don't know of any, and I just have to kind of follow the math wherever it takes me.
Edit: Any notion of conserved energy always originates from some kind of time-translational invariance of the physics describing a system's time evolution, e.g. the system's Lagrangian or Hamiltonian. If the EM field is considered to be dynamical and obeys Maxwell's equations (which are time-translationally invariant), then you get a conserved energy that includes the contribution from the EM field.
In your case you are specifying a non-dynamical background EM field and only considering the energy of the charged particle. In general, if the non-dynamical background EM field changes over time, then there is clearly no notion of conserved energy at all, because the particle can gain energy from the background field. In your case, the EM field is electrostatic and time-translationally invariant. However, this time-translational invariance can be "hidden" by a gauge field whose gauge degrees of freedom change over time. In this case the Lagrangian/Hamiltonian superficially changes over time, which messes up the formal conservation of energy. In order for the energy to be conserved, you need to work in a gauge that manifestly preserves the time-translational invariance (e.g. Coulomb gauge) so that you can use Noether's theorem. Without that condition, there's simply no reason to associate the quantity $q\, V({\bf r})$ with any kind of particle potential energy.
