Recently, the issue of energy efficiency in wireless networks has attracted much research attention due to the growing concern on global warming and operator's profitability. We focus on energy efficiency of base stations because they account for 80% of total energy consumed in a wireless network. In this paper, we intend to reduce energy consumption of a base station by dynamically activating and deactivating the modular resources at the base station depending on the instantaneous network traffic. We propose an online reinforcement learning algorithm that will continuously adapt to the changing network traffic in deciding which action to take to maximize energy saving. As an online algorithm, the proposed scheme does not require a separate training phase and can be deployed immediately. Simulation results have confirmed that the proposed algorithm can achieve more than 50% energy saving without compromising network service quality which is measured in terms of user blocking probability.