In this paper, we investigate a distributed beamforming problem to optimize energy efficiency (EE) in ultra-wideband (UWB) based implant body area networks (IBANs). To evaluate the impact of relay location on the EE, a relay location based cooperative network model is proposed, where multiple on-body relays are employed to assist an implant node to communicate with a BAN coordinator. With the proposed model, the EE optimization problem is mathematically formulated as a non-convex optimization problem. Sequential quadratic programming (SQP) combined with scatter search are applied to find the corresponding optimal solution. Simulation results illustrate that the proposed beamforming scheme outperforms other transmission schemes. A remarkable improvement can be achieved not only in EE but also in spectral efficiency (SE) compared to direct transmission. Moreover, numerical examples show that the relay location has a significant impact on the EE performance.