If $f:X\to Y$ is a proper morphism of noetherian shemes, then $f_*O_X=O_Y$ says that the fibers of $f$ are connected. This follows from a general form of Zariski's main theorem (Hartshorne III.11.3). Conversely, if $Y$ is in addition normal, then $f_*O_X=O_X$ holds. Indeed, there is a Stein factorization of the form $$ X \xrightarrow{f'} Z={\bf Spec} (f_* O_X) \xrightarrow{g} Y $$where $g$ is finite and $f'$ has connected fibers. Furthermore $g_*O_Z=O_Y$ and ${f'}_*O_X=O_Z$. If the fibers of $f$ are connected, then $g$ must be birational (by Hartshorne III.10.3) and is in fact an isomorphism if $Y$ is normal. It follows that $f_*O_X=O_Y$ if and only if $f$ has connected fibers.