Like anything, preparation is essential. Dig out old caulk and use a single edge razor to completely remove old stuff. Dig into the gap in the space between the tub and the tile wall.
Next, spray bleach into the crack and scrub with a tooth brush. This kills mold and funky stuff which, when it grows, discolors the caulk line. Let this treatment dry completely. I have used a blow dryer to speed the process.
Now, apply a thin-to-medium bead of caulk. You can smooth it with a plastic spoon. Some neat-freaks apply a line of tape on the tub first. Then when they remove the tape, they get a crisp, clean line. Do not get carried away with too much caulk -- just make sure you seal the gaps completely.
Let dry overnight before using. Spray with bleach or amold killer regularly to prevent return of the funky stuff. You don't want it getting in your feet.