It is widely recognised that compliant actuation is advantageous to robot control once dynamic tasks are considered. However, the benefit of intrinsic compliance comes with high control complexity. Specifically, coordinating the motion of a system through a compliant actuator and finding a task-specific impedance profile that leads to better performance is known to be non-trivial. Here, we propose an optimal control formulation to compute the motor position commands, and the associated time-varying torque and stiffness profiles. To demonstrate the utility of the approach, we consider an “explosive” ball-throwing task where exploitation of the intrinsic dynamics of the compliantly actuated system leads to improved task performance (i.e., distance thrown). In this example we show that: (i) the proposed control methodology is able to tailor impedance strategies to specific task objectives and system dynamics, (ii) the ability to vary stiffness can be exploited to achieve better performance, (iii) in systems with variable physical compliance, the present formulation enables exploitation of the energy storage capabilities of the actuators to improve task performance. We illustrate these in numerical simulations, and in hardware experiments on a two-link variable stiffness robot.