I would like to know under what condition the morphism $\mathcal{O}_Y\longrightarrow f_\ast \mathcal{O}_X$ induced by a morphism $f:X\longrightarrow Y$ of schemes is injective.

Let me give an example (which I'm not completely sure about though).

I believe, if $X$ and $Y$ are reduced and $f$ is surjective and closed, the morphism $\mathcal{O}_Y \longrightarrow f_\ast \mathcal{O}_X$ is injective.

(Thus, proper flat morphisms of varieties have this property.)

Maybe one could forget about schemes and give a condition for locally ringed spaces?