How to adjust the rear derailleur (gear)
The easiest way to do this is using the barrel adjuster on the derailleur. You can use it to tighten or loosen the cable slightly and get the shifting back to perfect and making the chain runs smoothly for all rear cogs.
If you look at the barrel adjuster from the point of view of the cable housing (not the bare cable) running into it, turning the adjuster clockwise will slacken the cable and counter-clockwise will tighten it. Adding slack (clockwise) to the rear derailleur should adjust the chain towards the small cog, tightening (counter-clockwise) moves it towards the large cog. If the barrel adjuster doesn't give you enough range, then you'll have to adjust the slack where the cable clamps into the derailleur. Try it out, you should be able to see small movements in the derailleur as you tweak the barrel adjuster.
Of course, there are a whole range of other problems that can affect shifting (worn chain, worn cogs, bad chain line, worn cable/housing, sticky derailleur, etc.), but the try this first.