We address the out-of-equilibrium thermodynamics of an isolated quantum system consisting of a cavity optomechanical device. We explore the dynamical response of the system when driven out of equilibrium by a sudden quench of the coupling parameter and compute analytically the full distribution of the work generated by the process. We consider linear and quadratic optomechanical coupling, where the cavity field is parametrically coupled to either the position or the square of the position of a mechanical oscillator, respectively. In the former case we find that the average work generated by the quench is zero, whilst the latter leads to a non-zero average value. Through fluctuations theorems we access the most relevant thermodynamical figures of merit, such as the free energy difference and the amount of irreversible work generated. We thus provide a full charac- terization of the out-of-equilibrium thermodynamics in the quantum regime for nonlinearly coupled bosonic modes. Our study is the first due step towards the construction and full quantum analysis of an optomechanical machine working fully out of equilibrium.