We describe a boundary-element method used to model the hydrodynamics of a bacterium propelled by a single helical flagellum. Using this model, we optimize the power efficiency of swimming with respect to cell body and flagellum geometrical parameters, and find that optima for swimming in unbounded fluid and near a no-slip plane boundary are nearly indistinguishable. We also consider the novel optimization objective of torque efficiency and find a very different optimal shape. Excluding effects such as Brownian motion and electrostatic interactions, it is demonstrated that hydrodynamic forces may trap the bacterium in a stable, circular orbit near the boundary, leading to the empirically observable surface accumulation of bacteria. Furthermore, the details and even the existence of this stable orbit depend on geometrical parameters of the bacterium, as described in this article. These results shed some light on the phenomenon of surface accumulation of micro-organisms and offer hydrodynamic explanations as to why some bacteria may accumulate more readily than others based on morphology.