I have seen several posts discussing difference between heat and work on this website, e.g. (link 1) and (link 2). However, none of them gives a clear picture to me.
The posts and Callen's textbook distinguish heat from work as follows: $$dU =dE_{\,macroscopic}+TdS$$. In other words, while both work and heat represent a flow of energy,
Work: coherently transferred & accompanies changes in macroscopic degrees of freedom
Heat: incoherently transferred & related with atomic (hidden) degrees of freedom
However, I think I need more than those explanations to distinguish heat from work. Let me give you an example.
Think of an isolated box containing dielectric particles that do not move. If we apply external electric field on the box, we may observe electric polarization.
Since the field affect all the particles coherently (as a surrounding coherently compresses volume of ideal particles during an adiabatic compression) and we can detect a macroscopic change (electric polarization), the field transfers energy in a form of work, i.e. electric work.
Is that mean $TdS=0$? No, because the number of possible microstates increases; each particle can have more diverse polarization states. If you are not convinced, think of $N$ quantum harmonic oscillators. If we give more energy to them, the entropy of oscillators increases, since each oscillator can have more diverse modes.
Then, we have a paradox here. The external field transferred electric work to the system, $$dU=dE_{\,electrical}$$ , but $$TdS\neq 0$$. Which form does the energy transferred by the field have? Heat or work? How can I distinguish work from heat?
For those who think the paradox is related with possible irreversibility of work:
In an adiabatic compression of ideal gas particles, heat is zero ($dS=0$), since
Increase of momentum phase space volume = decrease of coordinate phase space volume.
Similarly, if we apply generalized work $fdX$ (e.g. electric work, $\vec{E} \cdot d\vec{P}$) on a system both reversibly and adiabatically,
Increase/decrease of phase space volume due to the change in coordinate $X$ should be compensated by "something".
Otherwise, $fdX$ changes entropy, i.e. $fdX$ can be both heat and work. Then, what is "something"?