We study the domains in an ultrathin magnetic layer with perpendicular magnetization as a function of temperature. The domain spacing is given by the balance between the interface energy and the demagnetizing energy. The demagnetizing energy is calculated in a continuum theory which is valid provided that the domains are large compared with the lattice spacing. The temperature dependence of the interface energy arises from the entropy of the rough walls. This is obtained from the exact results for the two-dimensional Ising model. We predict that the domain size shrinks rapidly as the temperature is raised towards the transition.