If the generator cannot power the entire installation, you install the automatic change between your main panel and a sub-panel. Hence, you connect all essential loads to the sub-panel. If the generator can power the entire building, you need to connect the transfer switch before the main panel, as a sub-pane might not be required.