Bipedal locomotion remains one of the major open challenges of humanoid robotics. The common approaches are based on simple reduced model dynamics to generate walking trajectories, often neglecting the whole-body dynamics of the robots. As motions in nature are often considered as optimal with respect to certain criteria, in this work, we present an optimal control-based approach that allows us to generate optimized walking motions using a precise whole-body dynamic model of the robot, in contrast with the common approaches. The optimal control problem is formulated to minimize a set of desired objective functions with respect to physical constraints of the robot and contact constraints of the walking phases; the problem is then solved with a direct multiple shooting method. We apply the formulation with combinations of different objective criteria to the model of a reduced version of the iCub humanoid robot of 15 internal DOF. The obtained trajectories are executed on the real robot, and we carry out a discussion on the differences between the outcomes of this approach with the classic approaches.