Assuming that $f$ is finite (I'm not quite sure if you are), then $f_*\mathcal{O}_X$ is locally free if and only if $f$ is a flat morphism.
Like Peter Bruin says, you are asking the following: given a finite ring homomorphism $A\to B$, when is $B$ a locally free $A$-module? But there is a natural characterization of this! A finitely generated $A$-module is locally free if and only if it is flat, because a finitely generated module over a local ring is free if and only if it is flat.
Example 3 is a special case of this, because any surjective morphism to a regular one dimensional scheme is automatically flat (because any injection of a dvr into another ring is flat).
Edit: Worth noting that if $X,Y$ are regular and $f$ is finite and surjective, then $f$ is flat.