I don't think you can hope for any kind of useful conditions, here are just some
comments.

Even if $X$ is smooth, whether or not we demand the compactification
matters. Let for instance $X'$ be a smooth projective surface containing a $(-2)$-curve $C$,
i.e., $C$ is isomorphic to $\mathbb P^1$ with self-intersection $-2$. Put
$X:=X'u C$. Then there is no smooth compactification of $X$ with
complement of codimension $³2$ but there is a normal one. In fact $C$ can be
contracted to a point on a normal surface but that point is singular with a non-trivial
local fundamental group. This fundamental group is an invariant of $X$ at
infinity and would be trivial if we could add a smooth point instead.

I think (haven't checked) that there is also for surfaces a distinction between
proper and projective (non-smooth) compactifications. If one does the usual
thing of blowing up $10$ general points on a smooth cubic, then the complement
of the strict transform of the cubic has a proper compactification by adding
just one point but I don't think it has a projective such compactification.

If $X$ has a projective normal compactification $\overline X$ then there are
some necessary conditions such as the space of global functions being finite
dimensional. In fact for a line bundle on $\overline X$, its space of section
are the same on $X$ as on $\overline X$ and hence using an ample line bundle on
$\overline X$ we see that $\overline X$ is the $\mathrm Proj$ of the algebra of
sections of powers of some line bundle on $X$. If we furthermore assume that
$\overline X$ is smooth, then any line bundle on $X$ extends to $\overline X$
and will in particular have a finite dimensional space of sections.

Hence a reasonable question is if the condition that all line bundle have finite
dimensional spaces of sections is enough to get a (smooth?) compactification
with complement of codimension $>1$. I think that for surfaces the answer may be
positive but feel dubious about higher dimensions.