This is a comment, not an answer, but it's too long to fit into a comment window.

I don't know of a 'generic' condition on metrics on the torus that would guarantee that there are no null-homotopic closed geodesics, but then I'm not sure what 'generic' is supposed to mean.

For example, would it suffice to find some sort of 'open' condition (for example, that a metric be 'sufficiently close' in some appropriate sense to being flat) that would imply that there are no null-homotopic closed geodesics, or are we supposed to be trying to decide whether, given any metric on the torus, there is another metric arbitrarily 'close' to it that has no null-homotopic closed geodesics? (This second meaning is what I take to be the literal meaning of 'generic', which I think is unlikely to hold.)

Meanwhile here is an interesting, 'nongeneric' example that has no nontrivial symmetries (which is, itself, a 'generic' condition in a sense) and has no null-homotopic closed geodesics:

Let $a$ and $b$ be 'generic' positive smooth functions on $\mathbb{R}$, periodic of period $2\pi$, and consider the metric
$$
g = \bigl(a(x)+b(y)\bigr)(\mathrm{d}x^2 + \mathrm{d}y^2).
$$
which is doubly periodic and hence defines a metric on the torus $\mathbb{T} = \mathbb{R}/(2\pi\mathbb{Z}^2)$.

I will show that $g$ has no closed geodesics in $\mathbb{R}^2$.

To do this, note that this is a metric of Liouville type and hence all the unit speed geodesics satisfy the equations (i.e., 'conservation laws' or 'first integrals')
$$
\bigl(a(x)+b(y)\bigr)(\dot x^2+\dot y^2) = 1
\quad\text{and}\quad
\bigl(a(x)+b(y)\bigr)\bigl(b(y)\,\dot x^2 - a(x)\,\dot y^2) = c
$$
for some constant $c$. Given such a geodesic, let $\theta$ be the function on the geodesic that satisfies $\cos\theta = \dot x\sqrt{a(x)+b(y)}$ and $\sin\theta = \dot y\sqrt{a(x)+b(y)}$. This $\theta$ is well-defined up to an integer multiple of $2\pi$ and gives the 'slope' of the geodesic in the standard $xy$-coordinates. Then we have
$$
b(y)\,\cos^2\theta - a(x)\,\sin^2\theta = c.
$$
Notice that, because $a$ and $b$ are strictly positive, this equation implies that, for any given $c$, there is an open set of directions $\phi$ such that $\theta$ cannot attain either value $\phi$ or $\phi+\pi$, an impossibility for a closed curve in the $xy$-plane, since a closed curve has to have a tangent perpendicular to any given direction.

Thus, $g$ has no closed geodesics in $\mathbb{R}^2$ and hence the induced metric on $\mathbb{T}$ has no closed null-homotopic geodesics.

Of course, you can object that Liouville metrics are not 'generic'. But it might be that there is some 'open' condition on a lattice-periodic metric on the plane such that no geodesic satisfying this condition can ever 'turn all the way around', as in this Liouville case. If one can find such a condition, then this would, I take it, be an answer to Anton's question.

Moreover, there are `higher' Liouville metrics, i.e., for which the geodesic flow has higher degree polynomial conservation laws, and, as far as I know, there is no limit on how high the degree of such a conservation law might be. It's possible that one could find examples of arbitrary complexity, so that these metrics are as 'generic' as you could possibly want.

contractibleclosed geodesic." $\endgroup$