A search for weakly interacting massive dark-matter particles produced in association with bottom or top quarks is presented. Final states containing third-generation quarks and missing transverse momentum are considered. The analysis uses 36.1fb-1 of proton–proton collision data recorded by the ATLAS experiment at s=13 TeV in 2015 and 2016. No significant excess of events above the estimated backgrounds is observed. The results are interpreted in the framework of simplified models of spin-0 dark-matter mediators. For colour-neutral spin-0 mediators produced in association with top quarks and decaying into a pair of dark-matter particles, mediator masses below 50 GeV are excluded assuming a dark-matter candidate mass of 1 GeV and unitary couplings. For scalar and pseudoscalar mediators produced in association with bottom quarks, the search sets limits on the production cross-section of 300 times the predicted rate for mediators with masses between 10 and 50GeV and assuming a dark-matter mass of 1GeV and unitary coupling. Constraints on colour-charged scalar simplified models are also presented. Assuming a dark-matter particle mass of 35GeV, mediator particles with mass below 1.1TeV are excluded for couplings yielding a dark-matter relic density consistent with measurements.