The top quark pair production cross section is measured in proton-proton collisions at a center-of-mass energy of 5.02 TeV. The data collected in 2017 by the CMS experiment at the LHC corresponding to an integrated luminosity of 304 1/pb are analyzed. The measurement is performed using events with one electron and one muon of opposite sign, and at least two jets. The measured cross section is found to be 60.3 ± 5.0 (stat) ± 2.8 (syst) ± 0.9 (lumi) pb. To reduce the statistical uncertainty, a combination with the result in the l+jets channel, based on 27.4 1/pb of data collected in 2015 at the same center-of-mass energy, is then performed, obtaining a value of 62.6 ± 4.1 (stat) ± 3.0 ( syst+lumi ) pb, with a total uncertainty of 7.9%, in agreement with the standard model.