This is a special case of the following more general result "of Bertini type" about degeneracy loci of morphism of vector bundles. Let $\phi \colon F \to E$ be a morphism between vector bundles on $X$, with $\textrm{rank} \, F=s$, $\textrm{rank} \, E=r$, and let $D_k(\phi)$ the set of points $x \in X$ such that $\phi_x \colon F_x \to E_x$ has rank $\leq k$. If $F^{*} \otimes E$ is generated bu global sections, then for the general $\phi$ either $D_K(\phi)$ is empty or it has the expected codimension $(s-k)(r-k)$. In your case, apply this theorem to the morphism $\phi \colon \mathcal{O}_X \to E$ induced by the section. Since $D_0(\phi)$ is exactly the locus where the section vanishes, you are done.