The optimal control problem for a class of hybrid systems (switched Lagrangian systems) is studied. Some necessary conditions of the optimal solutions of such a system are derived based on the assumption that there is a group of symmetries acting uniformly on the domains of different discrete modes, such that the Lagrangian functions, the guards, and the reset maps are all invariant under the action. Lagrangian reduction approach is adopted to establish the conservation law of certain quantities for the optimal solutions. Some examples are presented. In particular, the problems of optimal collision avoidance (OCA) and optimal formation switching (OFS) of multiple agents moving on a Riemannian manifold are studied in some details.