A way to improve the performance of heat pumps lies in the possibility of adhering to Demand Response (DR) programs. DR consists of changes in electricity use of end users in response to changes in the electricity price over time. Taking advantage of the energy flexibility given by the end-use system, such as a building, it is possible to collect more electricity when its price is low, and to reduce its absorption when the price is high. In this work, a commercial air-to-water heat pump was experimentally characterized to assess its energy performance when managed with a DR program. A test rig based on a closed-loop system allowed to reproduce a thermal load in the condenser side. The thermal load was associated to the space heating demand of a virtual building, which was modeled with a resistance-capacitance thermal network. The DR program, based on a real-time pricing control strategy, managed the interaction between the closed-loop system and the virtual building, which was able to unlock its energy flexibility thanks to a variable indoor air setpoint temperature. Respect to a conventional control based on a fixed setpoint temperature, the DR-based configuration led to significant electrical energy and cost saving.