We propose a finite-size correction scheme for the formation energy of charged defects and impurities in one-dimensional systems within density functional theory. The energy correction in a supercell geometry is obtained by solving the Poisson equation in a continuum model which is described by an anisotropic permittivity tensor, with the defect charge distribution derived from first-principles calculations. We implement our scheme to study impurities and dangling bonds in silicon nanowires and demonstrate that the formation energy of charged defects rapidly converges with the supercell size.