The desired outcome of the research is to examine and empirically establish the effect of tax planning, deferred tax assets, deferred tax expense, and profitability on earnings management in energy sector firms established on the Indonesia Stock Exchange (IDX) between 2015-2020, with earnings quality as a moderating variable and leverage and firm size as control variables. According to the research object's criteria, the samples used in this research were 11 firms from 78 in the energy sector. Purposive sampling was used in the research, along with the Moderated Regression Analysis (MRA) test. According to the result of this research, tax planning, deferred tax expense, and profitability, all have a positive effect on earnings management, but deferred tax assets have no effect. Earnings quality, as a moderating variable, can mitigate the effects of tax planning on earnings management, but cannot mitigate the effects of profitability on earnings management. Furthermore, leverage has no effect on earnings management as a control variable, whereas firm size has a negative effect on earnings management. This research's contribution is a discussion of research results and differences with previous research results and related theories, and it can be implemented in every company's management in its operations for policy-making and management decisions for firms, particularly in the energy sector