This paper presents an efficient power allocation algorithm based on primary user (PU) activity for orthogonal frequency division multiplexing cognitive radio systems. Because of PU activity, the power allocation optimization problem becomes maximizing the sum expected capacity (i.e., the sum capacity minus the expected capacity loss), rather than maximizing the sum capacity in the traditional power allocation optimization problem. To solve this problem efficiently, we first transform the expected capacity loss into the peak power constraint and then reformulate the problem as maximizing the sum capacity under the peak power constraint. With this problem reformulation, the optimal power distribution can be reached by iteratively performing the water-filling (WF) algorithm. Instead of using the WF algorithm, we also propose a simple method to update the water level. Simulation results show that the proposed approach achieves a sum expected capacity close to that of the optimal solution, regardless of the change in the probability that the PU will reoccupy the subcarriers.