A search for exotic decays of the Higgs boson into a pair of spin-zero particles, , where the -boson decays into -quarks promptly or with a mean proper lifetime up to 6 mm and has a mass in the range of GeV, is presented. The search is performed in events where the Higgs boson is produced in association with a or boson, giving rise to a signature of one or two charged leptons (electrons or muons) and multiple jets from -quark decays. The analysis is based on the dataset of proton-proton collisions at TeV recorded in 2015 and 2016 by the ATLAS detector at the CERN Large Hadron Collider, corresponding to an integrated luminosity of fb. No significant excess of events above the Standard Model background prediction is observed, and 95% confidence-level upper limits are derived for the production cross-sections for , and their combination, times the branching ratio of the decay chain . For -bosons which decay promptly, the upper limit on the combination of cross-sections for and times the branching ratio of ranges from 3.0 pb for GeV to 1.3 pb for GeV, assuming that the ratio of to cross-sections follows the Standard Model prediction. For -bosons with longer proper lifetimes, the most stringent limits are 1.8 pb and 0.6 pb, respectively, at mm.