Let $H$ be a Hopf algebra over a field $k$ and $V, W$ two $H$-modules. The antipode and comultiplication on $H$ allow us to turn $\mathrm{Hom}_k(V, W)$ into a $H$-module by setting $$ (h \cdot f)(v) = h_{(1)}f( S(h_{(2)}) v ) $$ for $h \in H$, $f \in \mathrm{Hom}_k(V, W)$ and $v \in V$. Here $S: H \to H$ denotes the antipode and I am using (sumless) Sweedler notation.
For any $H$-module $V$ we can also define the module of $H$-invariant elements $V^H$ in $V$ as those $v \in V$ satisfying $h \cdot v = \varepsilon(v)$ where $\varepsilon$ denotes the counit of $H$. Now I'm wondering whether $$ \mathrm{Hom}_H(V, W) = \mathrm{Hom}_k(V, W)^H \,? $$ More explicitly: For $f \in \mathrm{Hom}_k(V, W)$, is $$ f(a v) = a f(v) \quad \forall a \in H, v \in V \tag{1} $$ equivalent to $$ a_{(1)} f(S(a_{(2)}) v) = \varepsilon(a) f(v) \quad \forall a \in H, v \in V \,? \tag{2} $$
It's easy to see that (1) implies (2), and I've managed to show that (2) implies (1) when $a = S(b)$ for some $b$, which shows it for all commutative or cocommutative $H$.
Yes, it is true that $\mathrm{Hom}_H(V, W) = \mathrm{Hom}_(V, W)^H$, without any further assumptions on $H$.
If $f \colon V \to W$ is $H$-linear, then $$ (h ⋅ f)(v) = h^{(1)} f( S(h^{(2)}) v) = h^{(1)} S(h^{(2)}) f(v) = ε(h) f(v) $$ for every element $v$ of $V$, and therefore $h ⋅ f = ε(h) f$. This means that $f$ is $H$-invariant.
Suppose conversely that $f$ is $H$-invariant. Then \begin{align*} f(h v) &= f( ε(h_{(1)}) h_{(2)} v ) \\[0.3em] &= ε(h_{(1)}) f( h_{(2)} v ) \\[0.3em] &= (h_{(1)} ⋅ f)( h_{(2)} v ) \\[0.3em] &= h_{(1)} f( S(h_{(2)}) h_{(3)} v ) \\[0.3em] &= h_{(1)} f( ε(h_{(2)}) v ) \\[0.3em] &= h_{(1)} ε(h_{(2)}) f(v) \\[0.3em] &= h f(v) \,. \end{align*}
This shows that $f$ is $H$-invariant.