A search for the standard model Higgs boson produced in association with a top-quark pair is presented using data samples corresponding to an integrated luminosity of 5.0 fb(-1) (5.1 fb-1) collected in pp collisions at the center-of-mass energy of 7 TeV (8 TeV). Events are considered where the top-quark pair decays to either one lepton+jets (t (t) over bar -> l nu q (q) over bar 'b (b) over bar) or dileptons (t (t) over bar -> l(+)nu l-nu b (b) over bar), being an electron or a muon. The search is optimized for the decay mode H -> b (b) over bar. The largest background to the t (t) over barH signal is top-quark pair production with additional jets. Artificial neural networks are used to discriminate between signal and background events. Combining the results from the 7 TeV and 8 TeV samples, the observed (expected) limit on the cross section for Higgs boson production in association with top-quark pairs for a Higgs boson mass of 125 GeV is 5.8 (5.2) times the standard model expectation.