Since you asked for reference, here are some references that may be helpful (the question is local):

1) (EDITED: Thanks to BCnrd for keeping me honest here!) If $(R,m)\to (S,n)$ is a map of Cohen-Macaulay local rings of same dimensions, $N$ a finite $S$-module which is $R$-~~free~~ flat then $${\rm{depth}}_ S N ={\rm{depth}} R = {\rm{depth}} S.$$

This follows from Prop 1.2.16 and Theorem A.11 of Bruns-Herzog "Cohen-Macaulay rings". Namely, take $M=R$ in both results, one get from A.11 that $\dim_SN = \dim_RN + \dim_SN/mN$, so $\dim_SN/mN=0$, then 1.2.16 gives ${\rm{depth}}_SN = {\rm{depth}} R$.

2) If $S$ is regular, then f.g modules with maximal depth are free.

This is well-known. It follows from Auslander-Buchsbaum formula, as Boyarsky pointed out.

EDIT: Just to be clear, it is enought to assume: $f$ is finite, $X$ regular, and $Y$ Cohen-Macaulay scheme (certainly true if $Y$ also regular or smooth, but is a much weaker condition). For example the map induced by $k[x,y]/(xy) \to k[x]$ by killing $y$ works.