The inequality does not hold in general.
Let $p$ be an odd prime, and let $G$ be the nonabelian group of order $p^3$ and exponent $p$ (or more generally, any nilpotent $p$-group of class $2$, $3$, or $4$, and exponent $p$). This is a $p$-group, so $Z(G)\neq 1$; being nilpotent of class $2$, it is metabelian.
Now, because $G$ is of exponent $p$, $f(G)=1$; since $G'$ is nontrivial and of exponent $p$, we also have $f(G') = 1$; and as $G/G'$ is abelian of exponent $p$, we again have $f(G/G') = 1$. Thus, $f(G')+f(G/G') = 1+1 = 2$, and $2f(G)=2$, giving equality. We don't get strict inequality here (or in any $p$-group of class$\leq 4$ and exponent $p$).