A solution for the general optimal control problem in generalized Lie algebroids is presented. This is a new point of view over optimal control theory. Indeed, Lagrangian formalism is developed in the general framefork of Lagrange distinguished mechanical systems