A search for a standard model Higgs boson decaying to tau pairs is performed using events recorded by the CMS experiment at the LHC in 2011 and 2012 at a center-of-mass energy of 7 and 8 TeV respectively. The dataset corresponds to an integrated luminosity of 10~, corresponding to 4.9~ of data taken at 7 TeV center-of-mass energy and 5.1~ of data taken at 8 TeV center-of-mass energy. No excess of events is observed in the tau-pair invariant-mass spectrum. In the mass range of 110--145~GeV upper limits at 95\% confidence level on the production cross section are determined. We exclude a Higgs boson with \mH=125~GeV with a production cross section 1.06 times that predicted by the standard model.