A classic problem in population and evolutionary biology is to understand how a population optimizes its fitness in fluctuating environments. A population might enhance its fitness by allowing individual cells to stochastically transition among multiple phenotypes, thus ensuring that some cells are always prepared for an unforeseen environmental fluctuation. Here we experimentally explore how switching affects population growth by using the galactose utilization network of Saccharomyces cerevisiae. We engineered a strain that randomly transitions between two phenotypes as a result of stochastic gene expression. Each phenotype was designed to confer a growth advantage over the other phenotype in a certain environment. When we compared the growth of two populations with different switching rates, we found that fast-switching populations outgrow slow switchers when the environment fluctuates rapidly, whereas slow-switching phenotypes outgrow fast switchers when the environment changes rarely. These results suggest that cells may tune inter-phenotype switching rates to the frequency of environmental changes.