Hadrons containing heavy quarks, i.e. charm and beauty, are effective probes to investigate the properties of the hot, dense and strongly-interacting medium formed in high-energy nuclear collisions. The relatively large masses of heavy quarks ensure that they are predominantly produced in the early stages of the collision and probe the complete space-time evolution of the expanding medium. The measurements of D-meson production in pp collisions provide an important test of pQCD calculations and serve as an essential baseline for the comprehensive studies in heavy-ion collisions. The study of D-meson production in p-Pb collisions is necessary to disentangle the cold nuclear matter effects from hot nuclear matter effects. The measurement of heavy-flavour production as a function of charged-particle multiplicity in pp and p-Pb collisions could provide insight into the role of multi-parton interactions at LHC energies.
We present ALICE results on D-meson production in pp collisions at $\sqrt{s} =$ 7 TeV and p-Pb collisions at $\sqrt{s_{\rm {NN}}}=$ 5.02 TeV. The D-meson yields per event, measured in different multiplicity intervals and normalized to their multiplicity-integrated values, are presented for pp and p-Pb collisions. The $p_{\rm {T}}$-differential production cross section and nuclear modification factor of prompt D mesons are measured in p-Pb collisions. The nuclear modification factor, $R_\mathrm{pPb}$, is compatible with unity within uncertainties, indicating that cold nuclear matter effects are small for $p_{\mathrm{T}} \gtrsim 3$ GeV/$c$. The D-meson transverse momentum distributions in p-Pb collisions relative to pp collisions, measured in several multiplicity classes, are also discussed.