Walking efficiency is one of the considerations for designing biped robots. This article uses the dynamic optimization method to study the effects of upper body parameters, including upper body length and mass, on walking efficiency. Two minimal actuations, hip joint torque and push-off impulse, are used in the walking model, and minimal constraints are set in a free search using the dynamic optimization. Results show that there is an optimal solution of upper body length for the efficient walking within a range of walking speed and step length. For short step length, walking with a lighter upper body mass is found to be more efficient and vice versa. It is also found that for higher speed locomotion, the increase of the upper body length and mass can make the walking gait optimal rather than other kind of gaits. In addition, the typical strategy of an optimal walking gait is that just actuating the swing leg at the beginning of the step.