This paper proposes a method to determine the optimal value of design parameters in robots driven by variable-stiffness actuators. The method consists of setting up a nonlinear optimization problem, the solution of which determines the optimal control sequence, and, at the same time, the optimal values of the parameters. As a case study, we analyze a ball-throwing problem for a two-link elbow manipulator actuated by antagonistic quadratic springs, and show results for different configurations. Even if similar methods have already been proposed, mainly in process control, this approach is novel when applied to robots, and could lead to an overall improvement of their design, exploiting numerical optimization tools, which, in the last years, have become faster and more reliable.