Geometric frustration in the kagome lattice makes it a great host for the flat electronic band, nontrivial topological properties, and novel magnetism. Here, we use magnetotransport measurements to map out the field-temperature phase diagram of the centrosymmetric YMn6Sn6 with a Mn kagome lattice and show that the system exhibits the topological Hall effect (THE) with an in-plane applied magnetic field around 240 K. In addition, our neutron diffraction results demonstrate that the observed THE cannot arise from a magnetic skyrmion lattice, but instead from an in-plane field-induced double-fan spin structure with -axis components. This paper provides a platform to understand the influence of a field-induced novel magnetic structure on magnetoelectric response in topological kagome metals.