The azimuthal correlations of D mesons with charged particles were measured with the ALICE apparatus in pp collisions at √s=7 TeV and p–Pb collisions at √sNN=5.02 TeV at the Large Hadron Collider. D0, D+, and D∗+ mesons and their charge conjugates with transverse momentum 30.3 GeV/c. The yield of charged particles in the correlation peak induced by the jet containing the D meson and the peak width are compatible within uncertainties in the two collision systems. The data are described within uncertainties by Monte-Carlo simulations based on PYTHIA, POWHEG, and EPOS 3 event generators.