Ad-hoc networks are a set of mobile nodes that are connected via a wireless channel. Some of the nodes in this network behave selfishly and do not send data to other nodes so that in order to increase network performance these nodes must be identified. A credit-based algorithm is proposed to detect the selfish nodes. Three watchdog nodes are selected to monitor suspicious nodes in each cluster. The cluster head nodes detect the existence of selfish nodes by controlling general features of network, such as delay, the total number of sent packets, the total number of received packets, throughput, and network traffic. The watchdog nodes send their comment on selfishness or cooperation of the node to the cluster head. Cluster head makes decisions with a majority vote on a suspicious node. The simulation results show that the rate of detection accuracy and the life time of network are considerably high and the false alarm rate and energy consumption are low comparing to that of similar methods.