  We show that it is possible to obtain a picture of equilibrium thermodynamics
on the apparent horizon in the expanding cosmological background for a wide
class of modified gravity theories with the Lagrangian density $f(R, \phi, X)$,
where $R$ is the Ricci scalar and $X$ is the kinetic energy of a scalar field
$\phi$. This comes from a suitable definition of an energy momentum tensor of
the "dark" component that respects to a local energy conservation in the Jordan
frame. In this framework the horizon entropy $S$ corresponding to equilibrium
thermodynamics is equal to a quarter of the horizon area $A$ in units of
gravitational constant $G$, as in Einstein gravity. For a flat cosmological
background with a decreasing Hubble parameter, $S$ globally increases with
time, as it happens for viable $f(R)$ inflation and dark energy models. We also
show that the equilibrium description in terms of the horizon entropy $S$ is
convenient because it takes into account the contribution of both the horizon
entropy $\hat{S}$ in non-equilibrium thermodynamics and an entropy production
term.
