With the rapid development of technologies such as wireless communications and the Internet of Things (IoT), the proliferation of IoT devices will intensify the competition for spectrum resources. The introduction of cognitive radio technology in IoT can minimize the shortage of spectrum resources. However, the open environment of cognitive IoT may involve free-riding problems. Due to the selfishness of the participants, there are usually a large number of free-riders in the system who opportunistically gain more rewards by stealing the spectrum sensing results from other participants and accessing the spectrum without spectrum sensing. However, this behavior seriously affects the fault tolerance of the system and the motivation of the participants, resulting in degrading the system’s performance. Based on the energy-harvesting cognitive IoT model, this paper considers the free-riding problem of Secondary Users (SUs). Since free-riders can harvest more energy in spectrum sensing time slots, the application of energy harvesting technology will exacerbate the free-riding behavior of selfish SUs in Cooperative Spectrum Sensing (CSS). In order to prevent the low detection performance of the system due to the free-riding behavior of too many SUs, a penalty mechanism is established to stimulate SUs to sense the spectrum normally during the sensing process. In the system model with multiple primary users (PUs) and multiple SUs, each SU considers whether to free-ride and which PU’s spectrum to sense and access in order to maximize its own interests. To address this issue, a two-layer game-based cooperative spectrum sensing and access method is proposed to improve spectrum utilization. Simulation results show that compared with traditional methods, the average throughput of the proposed TL-CSAG algorithm increased by 26.3% and the proposed method makes the SUs allocation more fair.