A wireless sensor network (WSN) faces a number of outsider and insider attacks, and it is difficult to detect and defend against insider attacks. In particular, an insider selective-forwarding attack, in which the attackers select some of the received packets to drop, most threatens a WSN. Compared to a distributed WSN, a cluster-based WSN will suffer more losses, even the whole network’s destruction, if the cluster head is attacked. In this paper, a scheme solving the above issues is proposed with three types of nodes, the Cluster Head (CH), the Inspector Node (IN) and Member Nodes (MNs). The IN monitors the CH’s transmission to protect the cluster against a selective-forwarding attack; the CH forwards packets from MNs and other CHs, and randomly checks the IN to ascertain if it works properly; and the MNs send the gathered data packets to the CH and evaluate the behaviors of the CH and IN based on their own reputation mechanism. The novelty of our scheme is that in order to take both the safety and the lifespan of a network into consideration, the composite reputation value (CRV) including forwarding rate, detecting malicious nodes, and surplus energy of the node is utilized to select CH and IN under the new suggested network arrangement, and the use of a node’s surplus energy can balance the energy consumption of a node, thereby prolonging the network lifespan. Theoretical analysis and simulation results indicate that the proposed scheme can detect the malicious node accurately and efficiently, so the false alarm rate is lowered by 25.7% compared with Watchdog and the network lifespan is prolonged by 54.84% compared with LEACH (Low Energy Adaptive Clustering Hierarchy).