Does the volume of a thermodynamic system always have to change for it to do work? Does the volume of a thermodynamic system always have to change for it to do work?
If yes,could you explain why?
And if no, could you provide the example of a system, where it is not neccesary.
 A: It depends on how you define work. Work is sometimes defined as pressure times a change in  volume ($p\Delta V$, or $\int p dV$ if the pressure is not constant), which is equivalent to force times distance, as John Rennie defines it in his answer. In this case it's necessary for the volume to change, purely from the definition.
However, another way to define work is something along the lines of "a change in energy that is not due to the transfer of heat or thermal radiation." In this case it is not necessary for the volume to change. A particular example where the word "work" is used in this way is in electronics, when one calculates the work involved in charging a capacitor as $\int V dQ$, where $V$ here is the voltage rather than the volume, and Q is the charge. In this case neither the volume of the capacitor nor the battery charging it changes, but work is said to be done because the internal energy of the capacitor has changed reversibly, without a transfer of heat.
To put it more mathematically, consider the fundamental equation of thermodynamics:
$$
d U = T dS - pdV + \sum_i \mu_i dN_i + \dots
$$
(where the "$\dots$" can include many other optional terms, including a $V dQ$ one for a capacitor). The right-hand side of this equation represents all the ways in which a system's energy can change. The first term ($T dS$) represents a transfer of heat. Some people define "work" as just the second term ($-p dV$), whereas others define it as the sum of all the other terms apart from the first one. Thus, with the second definition you can have work that's associated with a change in volume, but you can also have work that's associated with a change in the chemical composition, charge, or any other conserved quantity.
A: Mechanical work $dW_\mathrm{mech} = -pdV$ is due to a volume change for a pressure $p$. But other kind of thermodynamic works exist:


*

*Chemical work $dW_\mathrm{chem} = \mu dN$ involves change in composition $N$ for a chemical potential $\mu$.

*Electrical work $dW_\mathrm{elect} = -E dP$ involves change in electric dipole moment $P$ in presence of an electric field $E$.

*Magnetic work $dW_\mathrm{mag} = -B dM$ involves change in magnetic dipole moment $M$ in presence of a magnetic field $B$.

*Etcetera.
A: Yes, because work is force times distance moved. It's not immediately obvious that this means work can only be done if the volume changes, but have a look at How much work is needed to compress a certain volume of gas? where I went into this in some detail. If any parts of this aren't clear comment here and I can go into them in more detail.
