In this paper, a technique is proposed to prevent the Sybil attack on LEACH protocol in WSN. An optimized path is obtained when Sybil attack occurs on LEACH protocol during routing using an optimized algorithm. The proposed technique is based on Bee Colony Optimization (BCO) that helps to prevent the attack. The parameters chosen for the work are true positive rate, false positive rate and detection rate. The detection rate obtained using BCO is 96.5%. It also includes comparison with previous prevention methods of Sybil attack based on detection rate. The whole result simulation has been taken place in Matlab environment.