A search for flavor-changing neutral currents (FCNC) in events with the top quark and the Higgs boson is presented. The Higgs boson decay to a pair of b quarks is considered. The data sample corresponds to an integrated luminosity of 35.9 fb(-1) recorded by the CMS experiment at the LHC in proton-proton collisions at root s = 13TeV. Two channels are considered: single top quark FCNC production in association with the Higgs boson (pp -> tH), and top quark pair production with FCNC decay of the top quark (t -> qH). Final states with one isolated lepton and at least three reconstructed jets, among which at least two are associated with b quarks, are studied. No significant deviation is observed from the predicted background. Observed (expected) upper limits at 95% confidence level are set on the branching fractions of top quark decays, B(t -> uH) < 0.47% (0.34%) and B(t -> cH) < 0.47% (0.44%), assuming a single nonzero FCNC coupling.