Stated like this it can't be true. Indeed if $X$ is normal then by Hartogs lemma each embedding $O_{X-Z} \to E_{|X-Z}$ (i.e. a section of $E_{|X-Z}$) should extend to $O_X \to E$. But a priori $E$ can be without global sections. For example $E = O(-1) \oplus O(-1)$ on $P^2$. Maybe you want to have a subbundle which is trivial up to a twist?

UPD. If a twist is allowed then the answer is yes. Indeed, after an appropriate twist we can assume that $E$ is generated by a vector space $V$ of global sections, that is a map $V\otimes O_X \to E$ is surjective. Let $E' = Ker(V\otimes O_X \to E)$. It is a vector bundle on $X$. Consider the Grassmannian $Gr(r-1,V)$ of vector subspaces of rank $r-1$. Let $U$ denote the tautological subbundle. On the product $X\times Gr(r-1,V)$ we have a composition
$$
U\boxtimes O \to V\otimes O\boxtimes O \to O\boxtimes E.
$$
Let $Y$ be its discriminant locus (the scheme of points where the rank is $\le r-2$).
The fiber of $Y$ over a point $x \in X$ consists of all $(r-1)$-dimensional subspaces which intersect with the subspace $E'_x \subset V$ of codimension $r$. A simple parameter count shows that it has codimension 2 in the Grassmannian. Since this is true for all $x \in X$ we conclude that $codim Y = 2$. Hence for generic point $u \in Gr(r-1,V)$ the fiber $Y_u \subset X$ also has codimension 2. But since the corresponding map $O^{r-1} \to E$ is an embedding out of $Y_u$, we just take $Z = Y_u$ and restrict the above map to $X - Z$.