If we assum the underlying scheme is Notherian and reduced.
closed as too localized by David Roberts, Martin Brandenburg, Ben Webster♦ May 3 '11 at 15:12
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
Let $X$ be a smooth quasi-projective variety over a field of dimension $n$ and $Z\subseteq X$ a subvariety such that the depth of $\mathscr O_Z$ at a fixed (closed) point of $X$ is $d$. Assume that $n-d\geq 3$, i.e., the projective dimension of $\mathscr O_Z$ at that closed point of $X$ is at least $3$. Then consider a locally free sheaf that surjects onto the ideal sheaf of $Z$. That gives a morphism to $\mathscr O_X$ and its kernel cannot be locally free, because then the projective dimension of $\mathscr O_Z$ at that closed point of $X$ would be $2$.
On the other hand, if your morphism is surjective, then what you want is true. Just count the rank of stalks.