The ALICE detector is dedicated to the study of the high energy-density QCD matter produced in heavy-ion collisions. Important probes of this matter are heavy quarks (charm and beauty), as they are produced in the early stage of the collision via initial hard scatterings. Thus measurements of their production offer important information on the early stage of the collision and the parton-medium interaction. To quantify the measurements performed in Pb-Pb collisions it is necessary that the production in pp and p-Pb collisions is studied. In pp collisions, the measurement of heavy-flavour production cross sections not only provides the reference for heavy-ion studies, but also delivers critical tests of perturbative QCD. In p-Pb collisions, initial-state effects, due to the presence of a nucleus, can be accessed. Such effects include the modification of parton densities and k_T broadening, which can result from multiple soft scatterings of partons. In addition, the existence of possible final-state effects can also be investigated.
In this contribution we present the results of open heavy-flavour production measurements in pp and p-Pb collisions with ALICE. These results will include the measurement of D-meson production as a function of charged-particle multiplicity. The D mesons are reconstructed via hadronic decay channels at mid-rapidity, and the yields are measured in specific transverse-momentum intervals for various multiplicity ranges. We compare the transverse-momentum dependent evolution of the per-event yield of D mesons in different multiplicity intervals in the two collision systems to gain an understanding of the interplay between hard and soft contributions to particle production and to possibly obtain insight into the role of multiple hard partonic interaction. In addition, we present the D-meson nuclear modification factor in different multiplicity ranges, which is defined as the ratio of the D-meson yield in p-Pb and pp collisions scaled by the number of binary nucleon-nucleon collisions. Finally, the azimuthal correlation of D mesons and charged hadrons, and electrons from heavy-flavor hadron decays and charged hadrons at mid-rapidity will be discussed as a function of transverse momentum.