In this paper we consider the problem of optimizing the operation of a building heating system under the hypothesis that the building is included as a consumer in a Demand Response program. Demand response requests to the building are assumed to come from an external market or grid operator. The requests assume the form of price/volume signals specifying a volume of energy to be saved during a given time slot and a monetary reward assigned to the participant in case it fulfills the conditions. A receding horizon control approach is adopted for minimization of the energy bill, by exploiting a simplified model of the building. Since the resulting optimization problem is a mixed integer linear programming problem which turns out to be manageable only for buildings with very few zones, a heuristic is devised to make the algorithm applicable to realistic size problems as well. The derived control law is tested on the realistic simulator EnergyPlus to evaluate pros and cons of the proposed algorithm. The performance of the suboptimal control law is evaluated by comparison with the optimal one on a chosen test case