Inconsistencies in the literature on the effects of bilingualism on executive function (EF) highlight the need for work that identifies specific elements of bilingual experience that enhance specific components of EF. The current study investigated whether code-switching (shifting between languages) is one such bilingual experience that may strengthen task-switching (switching between two sets of rules) in a group of bilingual preschoolers. We measured children’s code-switching behaviors in two contexts (home and school), distinguishing between language switching (shifting languages when changing conversational partners) and language mixing (shifting languages within a sentence while talking to one conversational partner). We tested the hypotheses that frequency of switching languages would predict task-switching performance, and that frequency of mixing languages would predict task-switching performance, but to a lesser extent than language switching. Results showed that language switching did not predict task-switching performance, but that language mixing significantly predicted some aspects of task-switching performance. Findings identify code-switching experience as a possible mechanism of the bilingual advantage in young children, adding support to other work proposing that the benefits of bilingualism vary across the lifespan.