Cognitive radio has attracted a lot of attention recently as an effective method of alleviating the spectrum scarcity problem in wireless communications. However, the constraints imposed on cognitive radio networks as secondary networks restrict their achievable throughput and highlight the importance of efficient spectrum sensing and power allocation. In this paper, we focus on maximizing the ergodic throughput of the opportunistic spectrum access cognitive radio system proposed in [1] under both average transmit and interference power constraints. More specifically, we propose an algorithm that obtains the optimal power allocation strategy and target detection probability, which under the imposed average interference power constraint becomes an additional optimization variable in the ergodic throughput maximization of the cognitive radio system. Finally, we provide simulation results and discuss the effects of the power allocation and target detection probability on the achievable ergodic throughput of the cognitive radio system.