An error analysis is presented for the spectral-Galerkin method to the Helmholtz equation in 2-D and 3-D exterior domains. The problem in unbounded domains is first reduced to a problem on a bounded domain via the Dirichlet-to-Neumann operator, then a spectral-Galerkin method is employed to approximate the reduced problem. The error analysis is based on exploring delicate asymptotic behaviors of the Hankel functions and on deriving {\it a priori} estimates with explicit dependence on the wave number for both the continuous and discrete problems. Explicit error bounds with respect to the wave number are derived and some illustrative numerical examples are also presented.