In cartoons, what is created first - video or sounds?
It depends on the exact studio's process, but generally either an animatic (basically a roughly animated storyboard) or the audio is done first.  In the case of Family Guy and American Dad specifically, it sounds like they work on the audio and the animatic first.  The advantage to doing an animatic first is it can help the voice actors visualize what will be happening, but that makes the process take a bit longer (which is particularly bad for TV).

Once the final audio is done, the final animation can be done to match the sound.  It's actually fairly easy just looking at the wave file of an audio track to pick out where the syllables are, though there is also software that can be used to automatically identify the proper moments for different types of mouth movements with pretty decent accuracy.  Once you know all the key frames (the particular points in time that need to have a given mouth shape) it's pretty easy to animate in between them to get the proper facial movement.

While I was researching American Dad's particular process for this question, I also stumbled across this video from the Wall Street Journal that I thought might be of interest relating to the question.