Most sitcoms will have two or three main sets that face the audience (the bar and pool room, using Cheers as an example), and several less commonly used sets in other sections of the soundstage (Sam’s office and the restroom). Oftentimes, extra sets are also constructed in the free spaces behind and around the main sets that can be reused whenever needed (like Diane’s apartment or Carla’s house).
Depending on what soundstage they’re using, there may already be a plane set already, but if not, they either pre-shoot those scenes on another soundstage and play them to the audience for live responses, or they may shoot those scenes on another day with a different audience.
Any exterior or location shoots are prerecorded and played to a studio audience for live responses.
Sometimes scenes are intentionally shot without an audience, either for quiet, emotional moments, to avoid spoilers, or when stunts or special effects need to be added later. These scenes may either have a laugh track added later or be left with silence.
Finally, laughs can be added or subtracted in post-production (called “sweetening”).