Behavioral economics struggles to explain why people sometimes evaluate outcomes separately (narrow bracketing of mental accounts) and sometimes jointly (broad bracketing). We develop a theory of endogenous bracketing, where people set goals to tackle self-control problems. Goals induce reference points that make substandard performance painful. Evaluating goals in a broadly bracketed mental account insulates an individual from exogenous risk of failure; but because decisions or risks in different tasks become substitutes there are incentives to deviate from goals that are absent under narrow bracketing. Extensions include goal revision, naïveté about self-control, income targeting, and firms' bundling strategies.