We consider the problem of determining the optimal aggregate power consumption of a population of thermostatically controlled loads such as air conditioners. This is motivated by the need to synthesize the demand response for a load serving entity (LSE) catering a population of such customers. We show how the LSE can opportunistically design the aggregate reference consumption to minimize its energy procurement cost, given day‐ahead price, load forecast, and ambient temperature forecast, while respecting each individual load’s comfort range constraints. The resulting synthesis problem is intractable when posed as a direct optimization problem after Euler discretization of the dynamics, since it results in a mixed‐integer linear programming problem with number of variables typically of the order of millions. In contrast, in this paper, we show that the problem is amenable to continuous‐time optimal control techniques. Numerical simulations elucidate how the LSE can use the optimal aggregate power consumption trajectory thus computed, for the purpose of demand response.