It’s not quite correct. I’ll note internal energy $U$ rather than $E$. It is true for any process:
$$
dU=\delta W +\delta Q=-pdV+TdS
$$
It is only for reversible processes that you can identify the terms namely:
$$
\delta W= -pdV \\
\delta Q=TdS
$$
Note the sign and overall factor that differs from your expression of work. In general, when considering internal energy, the natural variables to work with are volume and entropy i.e. $V,S$.
Your reasoning would work if you had rather said for a reversible process:
$$
\delta W=-pdV \\
\delta Q= \frac{f+2}{2}pdV+\frac{f}{2}Vdp
$$
The second equation is actually consistent with the formula of entropy of an ideal gas and the formula for heat.
Hope this helps.