The issue of spectrum scarcity in wireless networks is becoming prominent and critical with each passing year. Although several promising solutions have been proposed to provide a solution to spectrum scarcity, most of them have many associated tradeoffs. In this context, one of the emerging ideas relates to the utilization of cognitive radios (CR) for future heterogeneous networks (HetNets). This paper provides a marriage of two promising candidates (i.e., CR and HetNets) for beyond fifth generation (5G) wireless networks. More specifically, a joint power allocation and user assignment solution for the multiuser underlay CR-based HetNets has been proposed and evaluated. To counter the limiting factors in these networks, the individual power of transmitting nodes and interference temperature protection constraints of the primary networks have been considered. An efficient solution is designed from the dual decomposition approach, where the optimal user assignment is obtained for the optimized power allocation at each node. The simulation results validate the superiority of the proposed optimization scheme against conventional baseline techniques.