Optimal control problems for underactuated mechanical systems can be seen as a higher-order optimization problem subject to higher-order constraints. In this paper we discuss the variational formalism for higher-order mechanical systems subject to higher-order constraints (that is, depending on higher-order derivatives as, for example, the acceleration) where the configuration space is a trivial principal bundle. An interesting family of geometric integrators can be defined using discretizations of the Hamilton's principle of critical action. This family of geometric integrators is called variational integrators, being one of their main properties the preservation of some geometric features (symplecticity, momentum preservation, good behavior of the energy). We construct variational integrators for higher-order mechanical systems on trivial principal bundles, its extension to the case of systems with higher-order constraints and we devote special attention to a class of controlled mechanical systems, underactuated mechanical systems.