The gas temperature structure of protoplanetary disks is a key ingredient for interpreting various disk observations and for quantifying the subsequent evolution of these systems. The comparison of low- and mid-$J$ CO rotational lines is a powerful tool to assess the temperature gradient in the warm molecular layer of disks. Spectrally resolved high-$J$ ($J_{rm u} > 14$) CO lines probe intermediate distances and heights from the star that are not sampled by (sub-)millimeter CO spectroscopy. This paper presents new {it Herschel}/HIFI and archival PACS observations of $^{12}$CO, $^{13}$CO and cii emission in 4 Herbig AeBe (HD 100546, HD 97048, IRS 48, HD 163296) and 3 T Tauri (AS 205, S CrA, TW Hya) disks. In the case of the T Tauri systems AS 205 and S CrA, the CO emission has a single-peaked profile, likely due to a slow wind. For all other systems, the {it Herschel} CO spectra are consistent with pure disk emission and the spectrally-resolved lines (HIFI) and the CO rotational ladder (PACS) are analyzed simultaneously assuming power-law temperature and column density profiles, using the velocity profile to locate the emission in the disk. The temperature profile varies substantially from disk to disk. In particular, $T_{rm gas}$ in the disk surface layers can differ by up to an order of magnitude among the 4 Herbig AeBe systems with HD 100546 being the hottest and HD 163296 the coldest disk of the sample. Clear evidence of a warm disk layer where $T_{rm gas} > T_{rm dust}$ is found in all the Herbig Ae disks. The observed CO fluxes and line profiles are compared to predictions of physical-chemical models. The primary parameters affecting the disk temperature structure are the flaring angle, the gas-to-dust mass ratio the scale height and the dust settling.