A search for a light charged Higgs boson () decaying to a W boson and a CP-odd Higgs boson (A) in final states with or is performed using data from pp collisions at 13 TeV, recorded by the CMS detector at the LHC and corresponding to an integrated luminosity of 35.9 fb. In this search, it is assumed that the boson is produced in decays of top quarks, and the A boson decays to two oppositely charged muons. The presence of signals for boson masses between 100 and 160 GeV and A boson masses between 15 and 75 GeV is investigated. No evidence for the production of the boson is found. Assuming branching fractions 1 and , upper limits at 95% confidence level on the branching fraction of the top quark, , of 0.63 to 2.9% are obtained, depending on the masses of the and A bosons. These are the first limits on in the decay mode of the boson: .