Obtain a vocal-free accompaniment track of the song you want. Use a karaoke CD track, a MIDI file, or have a pianist play the accompaniment for recording. Transfer this file into your multi-track software, making it its own track. Follow the instructions in the program's manual or Help files to do this correctly with your software.
Record your voice as a separate track alongside the accompaniment track, using multi-track recording software. Again, follow the software's instructions. Listen to the accompaniment track on headphones while singing so you'll sing in sync with the accompaniment; however, sounds of singing and accompaniment will remain separate. This makes for better sound and lets you try multiple takes.
Listen to the combined tracks repeatedly to memorize your performance. Though you will naturally repeat your own performance in a very similar manner, for good lip synching, you'll want to listen to this particular performance so many times that the sound of it is second nature to you.
Sing along with the track quietly while it's turned up to a high volume. This will make the track as loud in your own head as what you're singing, helping you focus on the sound with which you're trying to get in synch.
Practice singing along with the track in front of a mirror. Keep the singing quiet and the track loud. Watch your mouth movements to make sure they line up, but also keep track of things like your facial expressions, body posture, gestures and how widely you open your mouth. All of these should line up with what you're hearing.
Mouth the song without singing in front of the mirror. If you have trouble making this look natural, continue singing along with the track, practicing over and over while getting softer each time.
Videotape yourself without a mirror to judge your progress. In a performance, you won't be able to assess yourself as you go, so it's important to master your synching without being able to watch yourself.