How this formula for work follows from the definition?

If a particle moves along a path $\gamma : I\subset \mathbb{R}\to \mathbb{R}^3$ then the work done by a force $\mathbf{F}$ is defined by

$$W = \int_{\gamma} \mathbf{F} = \int_{I}\mathbf{F}(\gamma(t))\cdot \gamma'(t) dt.$$

If $\mathbf{F}$ happens to be the total force, then we can use Newton's second law to prove that

$$W = \Delta K,$$

with $K$ being the kinectic energy. All of this is all right, but the problem is that I'm taking a course on electrodynamics and the teacher said that the work $W_{\mathrm{ext}}$ done by one force external to the system is

$$W_{\mathrm{ext}} = \Delta K + \Delta U,$$

that is the change in the total energy of the system. I don't know where this comes from, indeed with that definition of work we would have simply $W = \Delta K$ for the total force, not one external force. So what is really going on here? What this formula means and how can it be derived?

EDIT: From Thermodynamics, I know that if we have a thermodynamical system with internal energy $E$ then by the first law $\Delta E = Q + W$. Now, if we were to consider $E$ the mechanical energy, that is $E = K + U$, if $Q = 0$ then we would get the formula. That is all nice, but I don't think this applies here. Why? Well, because I don't think a system of charges form a thermodynamic system. Indeed, a thermodynamic system usually refers to macroscopic matter, not point particles carrying a charge. More than that, Thermodynamics is meant to study equilibrium states of macroscopic matter, which we are certainly not doing, since although source charges are fixed, those feeling the field can (and will) move around. Is my reaoning right here?

Energy is conserved, so you always have to ask whose energy, and where did it come from. Because the same number could appear with opposite signs in different places. So we know the kinetic energy, it's the kinetic energy of the unnamed particle experiencing all these named forces. But what about the potential energy, where did it come from?

Let's name lots more things. We can fix name to the particle, which I'll call $\gamma(t)$ since that's how it moves. What if you had more forces: $\vec{F}_{ext,i}$, $\vec{F}_{int,j}$, etcetera. The internal ones might sum to zero if they come in action-reaction pairs. The external ones too might have equal and opposite pairs but they affect different particles. So you might write:

$$W_{total} = \int_{I}\left(\sum_i \vec{F}_{ext,i} (\gamma(t))\right)\cdot \gamma'(t) dt=\Delta K.$$

Now a potential energy might be derived from some conservative forces. So what if all except maybe the first external force $\vec{F}_{ext,1}$ were conservative? Then we could make a potential energy due to all of them and get:

$$\Delta U=-\int_{I}\left(\sum_{i,i\neq 1} \vec{F}_{ext,i} (\gamma(t))\right)\cdot \gamma'(t) dt.$$

Now we can get an expression for $\Delta K + \Delta U$:

\begin{align}\Delta K + \Delta U& = \int_{I}\left(\sum_i \vec{F}_{ext,i} (\gamma(t))\right)\cdot \gamma'(t) dt -\int_{I}\left(\sum_{i,i\neq 1} \vec{F}_{ext,i} (\gamma(t))\right)\cdot \gamma'(t) dt \\ &= \int_{I} \vec{F}_{ext,1} (\gamma(t))\cdot \gamma'(t) dt. \end{align}

This might be nice, but it's hard to know for sure if that's what was intended.

Now you mentioned electromagnetism, and there aren't any conservative forces in general, and the forces can depend on velocity too, so we'd have to write out $\vec{F}\left(\gamma(t),\gamma'(t)\right)$ instead of $\vec{F}\left(\gamma(t)\right)$, and I don't see any clear winner for potential energy: springs? newtonian gravity? electrostatic forces? Many possibilities exist, but this seems like opinion based speculation at this point.

All of this is all right, but the problem is that I'm taking a course on electrodynamics and the teacher said that the work $W_{\mathrm{ext}}$ done by one force external to the system is $$W_{\mathrm{ext}} = \Delta K + \Delta U,$$ that is the change in the total energy of the system. I don't know where this comes from

It follows from the work-energy theorem for Newtonian systems, such as gravitationally interacting system of bodies (which can be ascribed potential energy $U$). In electrodynamics, things are actually more complicated.

When you express the total work as sum of works of individual forces, you can isolate the group of terms that are due to internal forces and express that work as $\Delta U$. That's all - its just a rewrite of the work-energy theorem.