A joint power control and relay selection scheme is considered for a cooperative and cognitive radio system where a secondary network shares spectrum with the primary network. In the secondary network, two secondary users (SUs) communicate with each other via an assist relay. The main point is to provide the best system performance to SUs while maintaining the interference power at primary user (PU) under a certain level. Using convex optimization, a closed-form solution is obtained when optimizing the power allocation among the two nodes and relay. Based on this result, a joint power control and relay selection scheme with fewer variable dimensions is proposed to maximize the achievable rate of the secondary system. Simulation results demonstrate that the sum rate of the cognitive two-way relay network increases compared with a random relay selection and fixed power allocation.