The maximum principle combined with numerical methods is a powerful tool to compute solutions for optimal control problems. This approach turns out to be extremely useful in applications, including solving problems which require establishing periodic trajectories for Hamiltonian systems, optimizing the production of photobioreactors over a one-day period, finding the best periodic controls for locomotion models (e.g., walking, flying, and swimming). In this paper, we investigate some geometric and numerical aspects related to optimal control problems for the so-called Purcell three-link swimmer , in which the cost to minimize represents the energy consumed by the swimmer. More precisely, employing the maximum principle and shooting methods, we derive optimal trajectories and controls, which have particular periodic features. Moreover, invoking a linearization procedure of the control system along a reference extremal, we estimate the conjugate points play a crucial role for the second order optimality conditions.We also show how, making use of techniques imported by the sub-Riemannian geometry, the nilpotent approximation of the system provides a model which is integrable, obtaining explicit expressions in terms of elliptic functions. This approximation allows us to compute optimal periodic controls for small deformations of the body, allowing the swimmer tomoveminimizing its energy. Numerical simulations are presented using Hampath and Bocop codes.