Let $X$ be scheme. Consider an extension $$ 0 \to \mathcal{O}_X^n \to E \to \mathcal{O}_X^m \to 0 $$ with $E$ a locally free $\mathcal{O}_X$-module.
My question is : does $E$ have to be free ? I think it's false but I couldn't find a counter example.
This is related to the following question : is a locally free $\mathcal{O}_X$-module projective in the category of quasi-coherent sheaves over $X$ ?
This is true (I think) if $X$ is affine since in this case a locally free sheaf is just a locally free module over a ring which is projective. But I don't think it's true over a general scheme although I don't know a counter example.
The link with my question is that if locally free sheaves are projective it would mean that the above exact sequence has a section and thus $E$ is free.
No. As in the comments, the issue is precisely that $\text{Ext}^1(\mathcal{O}, \mathcal{O}) \cong H^1(X, \mathcal{O})$ need not vanish. For example, if $X$ is a smooth projective curve of genus $g$ then we have
$$\dim H^1(X, \mathcal{O}) = g$$
and so we have nontrivial extensions of $\mathcal{O}$ by $\mathcal{O}$ whenever $g \ge 1$, e.g. if $X$ is an elliptic curve as also mentioned in the comments.