Cognitive control is thought to regulate the conflict between stability---maintaining the current task in the face of distraction---and flexibility---switching to a new task of greater priority. However, evidence conflicts regarding when and to what extent stability and flexibility trade-off. A normative theory of flexibility and stability may help clarify when and why we should expect such trade-offs to occur. Towards such a theory, we model task-switching as a problem of decision-making under uncertainty, in which the decision-maker must simultaneously infer both the identity of a stimulus and the task governing the correct response to that stimulus. We find that optimal behavior is either extremely stable or extremely flexible, but not both, indicating a normative basis for a trade-off between the two. However, we also show that a sub-optimal but more realistic decision-maker exhibits behavior between these two extremes, and more closely resembles experimental data.