We will use Corollary 3.39 of Hatcher's Algebraic Topology book, paraphrased to fit this problem better. (It is a corollary of Poincar$\acute{\text{e}}$ duality.)
Suppose $M$ is a closed orientable $n$-manifold. Choose once and for all a nonzero element $z\in H^n(M;\mathbb{Q})$. Then, for any $0\neq x\in H^k(M;\mathbb{Q})$ (with $k\leq n$), there is a cohomology class $y\in H^{n-k}(M;\mathbb{Q})$ such that $x\cup y = z$.
How does this help with your specific problem?
Well, choose $0\neq z\in H^n(Y;\mathbb{Q})$ once and for all. The hypotheses of the problem guarantee $f^\ast(z) \neq 0$. Now, let $0\neq x\in H^k(Y;\mathbb{Q})$. We want to show $f^\ast(x)\neq 0$. By the above corollary, we know $x\cup y = z$ for some appropriate choice of $y$. Then $0\neq f^\ast(z) = f^\ast(x\cup y) = f^\ast(x)\cup f^\ast(y)$, so $f^\ast(x)\cup f^\ast(y) \neq 0$. This shows $f^\ast(x)\neq 0$.
Edit I misinterpeted ronald's last comment to be about cohomology rather than homology. I believe his comment is correct and should follow from naturality of Poincar$\acute{\text{e}}$ duality. Nonetheless, I'm leaving the example up because there may be some pedagogical value in doing so.
Finally, as to your last comment, the problem is not equivalent to showing $f^\ast$ is surjective, since we don't know $H^k(Y;\mathbb{Q})$ and $H^k(X;\mathbb{Q})$ have the same dimension (as $\mathbb{Q}$-vector spaces). In fact, the map $f:S^1\times S^1\rightarrow S^2$ collapsing the one skeleton of $S^1\times S^1$ to a point is injective on $H^2$ (and thus, by the problem we just did it's injective on $H^0$ and $H^1$), but it is not surjective on $H^1$.