Observations of molecular gas in high-z star-forming galaxies typically rely on emission from CO lines arising from states with rotational quantum numbers J > 1. Converting these observations to an estimate of the CO J=1-0 intensity, and thus inferring H2 gas masses, requires knowledge of the CO excitation ladder, or spectral line energy distribution (SLED). The few available multi-J CO observations of galaxies show a very broad range of SLEDs, even at fixed galaxy mass and star formation rate, making the conversion to J=1-0 emission and hence molecular gas mass highly uncertain. Here, we combine numerical simulations of disk galaxies and galaxy mergers with molecular line radiative transfer calculations to develop a model for the physical parameters that drive variations in CO SLEDs in galaxies. An essential feature of our model is a fully self-consistent computation of the molecular gas temperature and excitation structure. We find that, while the shape of the SLED is ultimately determined by difficult-to-observe quantities such as the gas density, temperature, and optical depth distributions, all of these quantities are well-correlated with the galaxys mean star formation rate surface density (Sigma_SFR), which is observable. We use this result to develop a model for the CO SLED in terms of Sigma_SFR, and show that this model quantitatively reproduces the SLEDs of galaxies over a dynamic range of ~200 in SFR surface density, at redshifts from z=0-6. This model should make it possible to significantly reduce the uncertainty in deducing molecular gas masses from observations of high-J CO emission.