When is the push-forward of the structure sheaf locally free Let $f:X\longrightarrow Y$ be a morphism of noetherian schemes. Under what conditions is $f_\ast \mathcal{O}_X$ a locally free $\mathcal{O}_Y$-module?
Example 1. Suppose that $f$ is affine. Then $f_\ast\mathcal{O}_X$ is a quasi-coherent $\mathcal{O}_Y$-module.
Example 2. Suppose that $f$ is finite. Then $f_\ast \mathcal{O}_X$ is even coherent.
Example 3. Suppose that $f:X\longrightarrow Y$ is a finite morphism of regular integral 1-dimensional schemes. Then $f_\ast \mathcal{O}_X$ is coherent and locally free. (The local rings $\mathcal{O}_{Y,y}$ are discrete valuation rings.)
In view of the above examples, I'm basically looking for a higher-dimensional analogue of Example 3. But, I don't require quasi-coherence in my question. (Although this is quite unnatural.)
Idea. For any finite morphism $f:X\longrightarrow Y$, we have that $f_\ast \mathcal{O}_X$ is locally free. Only what are the precise conditions on $X$ and $Y$?
 A: One should probably also mention the "miracle flatness" theorem: If $f: X \to Y$ is finite, $X$ and $Y$ have the same dimension, $X$ is Cohen-Macaulay and $Y$ is regular, then $f$ is flat. As everyone has mentioned above, finite and flat implies locally free, so this theorem can be one useful way to get the flatness hypothesis.
A: It is of course not true that for any finite morphism $f:X\to Y$ we have $f_*\mathcal{O}_X$ locally free : think about a closed immersion.
In fact, your question is about the important topic of "base change and cohomology of sheaves" for proper morphisms, which is treated by Grothendieck in EGA3. The simplest answer one can give, I think, is that if $f$ is proper [EDIT : and flat, as t3suji points out] and for all $y\in Y$ we have $H^1(X_y,\mathcal{O}_{X_y})=0$ then $f_*\mathcal{O}_X$ is locally free.
You may want to avoid going to find the exact reference in EGA3, since as Mumford says, that result is "unfortunately buried there in a mass of generalizations". In that case, go to chapter 0, section 5 of Geometric Invariant Theory (3rd ed.) by Mumford, Fogarty and Kirwan. This is where Mumford's comment is taken from.
A: If $f\colon X\to Y$ is a finite morphism, then $f_*O_X$ is usually not locally free; for example, consider the inclusion of a point into the affine line.  The question is: given a ring homomorphism $A\to B$ such that $B$ is a finitely generated $A$-module, is $B$ locally free?  There is not really a useful property of $f$ that would imply this non-tautologically.
As Matthieu Romagny said (his answer arrived while I was writing mine), the real question is about proper morphisms.  You may also be interested in Hartshorne, Algebraic Geometry, III.12.
A: Well, if you have a finite flat morphism as Matthew Morrow says above.
Also, this may or may not be relevant eventually, but with regards to analogues of (3) with the higher direct images (and in higher relative dimension, ie non-finite morphisms), you might also want to check out Steenbrink's paper (and Du Bois's earlier paper).
http://www.numdam.org/item?id=CM_1980__42_3_315_0
http://www.numdam.org/item?id=BSMF_1981__109__41_0
See in particular Theorem 1 (and Theorem 4.6).
It says that if $f : X \to Y$ is flat (EDIT: and proper) and the fibers have nice enough singularities, then $R^i f_* O_X$ is locally free for all $i$.  There's also a recent preprint on the arXiv of Kollar and Kovacs on Du Bois singularities which deals with some things related to this at the end, see:
https://arxiv.org/abs/0902.0648
A: 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.
