Yes, the formula you quote applies to some extend.
It can also be written in terms of Boltzmann's constant $k_\mathrm{B}$ as
$$v_\mathrm{rms} = \sqrt{\frac{3k_\mathrm{B}T}{m_\mathrm{m}}},$$
with $m_\mathrm{m}$ the mass of the molecule in question,
gives the mean ("root-mean-square") velocity of the gas molecules as a function of temperature $T$. Comparing this to the escape velocity
$$v_\mathrm{esc}=\sqrt{\frac{2GM_\mathrm{p}}{R_\mathrm{p}}},$$
where $M_\mathrm{p}$ and $R_\mathrm{p}$ are the mass and radius of the planet, respectively, gives an order-of-magnitude estimate of whether or not the planet will be able to maintain its atmosphere.
However, if the two velocities are equal, it would still mean that half of the atmosphere evaporated instantly, and that over time, a large fraction would disappear, although the time scale for this to happen may be very long. In order for the planet to really sustain its atmosphere, $v_\mathrm{esc}$ needs to be roughly 6 times larger than $v_\mathrm{rms}$.
Gravity is not the only factor determining the stability of the atmosphere, though. Radiation pressure from the star ("Solar wind") can easily rip a planet of its atmosphere. On the other hand, if the planet has an efficient magnetic field, this will shield it against the wind.
Other factors are also involved. But you're right in that at the very least, the planet needs a certain gravitational field to keep its atmosphere.