Compliance is a property of human locomotion that has been largely investigated, both at muscle and joint level. Many studies are focused on leg joints in order to create mechanisms able to reproduce human-like gaits such as prostheses, exoskeletons or walking robots. A common approach is to look for a suitable stiffness for a linear spring that can approximate the behavior of a specific joint in a certain walking phase. In this paper the objective is instead to analyze the modulation of stiffness in the joints of human lower limbs during a single ground level walking step. Torsional springs with variable stiffness are introduced in the hip, knee and ankle joints of a 2D human model, as well as a damper in the ankle joint to avoid oscillations. Optimal control is applied to compute the variable stiffness, the rest positions of the springs and the value of the damper at the ankle that best reproduce human joint trajectories during level ground walking.