Heavy quark correlations in hadron collisions at next-to-leading order