This is true if $X$ satisfies Serre's condition $S_2$, i.e. $\mathcal O_X$ is $S_2$. Then a vector bundle is $S_2$ since locally it is isomorphic to $\mathcal O_X^n$.

More generally, a coherent sheaf $F$ on a Japanese scheme (for example: $X$ is of finite type over a field) which is $S_2$ has a unique extension from an open subset $U$ with $\operatorname{codim} (X\setminus U)\ge 2$. This follows at once from the cohomological characterization of $S_2$.

Thus, another name for the $S_2$-sheaves: they are sheaves which are *saturated in codimension 2*, and another name for the $S_2$-fication: *saturation in codimension 2*.

P.S. Of course, by Serre's criterion, normal = $S_2+R_1$. So the above statement is true for any normal (e.g. smooth) variety.

P.P.S. And of course, Gorenstein implies Cohen-Macaulay implies $S_2$. So the statement is also true for hypersurfaces and complete intersections, which could be very singular and non-reduced.

Edit to define some terms:

A Japanese (or Nagata) ring is a ring obtained from a ring finitely generated over a field or $\mathbb Z$ by optionally applying localizations and completions. The property used here is that for a Japanese ring $R$, its integral closure (normalization) $\tilde R$ is a finitely generated $R$-module. This is important because the $S_2$-fication $S_2(R)$ lies between $R$ and $\tilde R$.

A coherent sheaf $F$ satisfies $S_n$ if for any point $x\in Supp(F)$, one has
$$ depth_x (F) \ge \min(\dim_x Supp(F),n) $$
If $F$ locally corresponds to an $R$-module $M$, and $x$ to a prime ideal $p$, then the depth is the length of a maximal regular sequence $(f_1,\dots, f_k)$ of elements of $R_p$ for $M_p$ (so, $f_1$ is a nonzerodivisor in $M_p$, etc.).