The OPERA detector at the Gran Sasso underground laboratory (LNGS) was used to measure the atmospheric muon charge ratio $R_{\mu}=N_{\mu^{+}}/N_{\mu^{-}}$ in the TeV energy region. We analyzed 403069 atmospheric muons corresponding to 113.4 days of livetime during the 2008 CNGS run. We computed separately the muon charge ratio for single and for multiple muon events in order to select different energy regions of the primary cosmic ray spectrum and to test the R μ dependence on the primary composition. The measured R μ values were corrected taking into account the charge-misidentification errors. Data have also been grouped in five bins of the “vertical surface energy” ℰ μ cos θ. A fit to a simplified model of muon production in the atmo...