Record the scene dialogue. Many films will record the actor's vocal performance first in order to have an accurate reference to animate to. If your actor is not available, you can record yourself reading a sample or reference track but adjustments will be needed later after you record the final audio.
Define all of the phoneme shapes needed for your character's mouth. Look for charts on the Internet or watch yourself in the mirror and say the dialogue one syllable at a time. Observe the way your lips form for each sound, and sketch out each variation as a visual reference.
In your 2D animation application, draw out all of the individual phoneme shapes and save them. If you make yourself a collection of the different mouth formations, you may save yourself a lot of time during the animation process. Applications like Photoshop or Illustrator are good for this kind of work.
Import your audio track. Most 2D animation applications will allow you to import at least one track for the purpose of syncing animation with dialogue. Play back the audio slowly and listen to each sound. Import the appropriate phoneme images you saved before and apply them to the character's face.
Play the animation back after you have completed a line of dialogue. You may need to adjust frame duration or positioning of each mouth image to make the animation look more natural. Make sure that the mouth placement is consistent with the previous frames. If you are satisfied with the results then repeat this method for the remaining dialogue.