  We calculate the balance function for charm in relativistic heavy-ion
collisions. The distribution of pairs of charm-anticharm quarks produced in
hard processes in the early stages of the nucleus-nucleus collision evolves in
the dense fireball formed in the collision. The evolution of the dense matter
is described using a relativistic viscous hydrodynamic model and the quark
diffusion with a Langevin equation. The evolution of the charm quark balance
function from the formation of the charm-anticharm pair up to the freeze-out
traces the partial thermalization of the heavy quarks in the dense matter. For
the balance function in azimuthal angle we reproduce the collimation effect due
to the transverse flow. The evolution in rapidity shows the thermalization of
the longitudinal velocity of the quark in the fluid. We provide predictions for
the one and two-dimensional balance functions for $D^0$-$\bar{D^0}$ mesons
produced in ultarelativistic Pb+Pb collisions at $\sqrt{s_{NN}}=5.02$ TeV. The
shape of the charm balance function in relative rapidity is sensitive to the
rescattering of heavy quarks in the early stages of the collision, while the
shape of the balance function in azimuthal angle is sensitive to the
rescattering in the latter stages.
