In this paper, we propose an energy-efficient small cell operation algorithm for ultra-dense cellular networks to improve the energy efficiency of the networks. To that end, the algorithm generates a dataset consisting of the location information of inactive small cells and static UEs. For an overload condition in a macro cell, the algorithm performs clustering with the density-based spatial clustering of applications with noise to find clusters with small cells. Therefore, based on conditions a target cluster is selected and the small cells in the cluster are switched to the active mode in order to share loads from the macro cell. For an under-load scenario in the macro cell, the algorithm finds a small cell with the lowest radio load and conditionally switches the cell to sleep mode. Through systemlevel simulations, the performance of the proposed algorithm is evaluated. The simulation results showed that the proposed approach can ensure a higher energy efficiency than previous algorithms.