The primary user emulation attack (PUEA) is one of the common threats in cognitive radio networks (CRNs), in this problem, an attacker mimics the Primary User (PU) signal to deceive other secondary users (SUs) to make them leave the white spaces (free spaces) in the spectrum assigned by the PU. In this paper, the PUEA is detected and localized using the Time-Difference-Of-Arrival (TDOA) localization technique. Particle Swarm Optimization (PSO) algorithms are proposed to solve the cost function of TDOA measurements. The PSO variants are developed by changing the parameters of the standard PSO such as inertia weight and acceleration constants. These approaches are presented and compared with the standard PSO in terms of convergence speed and processing time. This paper presents the first study of designing a PSO algorithm suitable for the localization problem and will be considered as a good guidance for applying the optimization algorithms in wireless positioning techniques. Mean square error (MSE) and cumulative distribution function (CDF) are used as the evaluation metrics to measure the accuracy of the proposed algorithms. Simulation results show that the proposed PSO approaches provide higher accuracy and faster convergence than the standard PSO and the Taylor series estimation (TSE).