Community structure is an interesting feature of complex networks. In recent years, various methods were introduced to extract community structure of networks. In this study, a novel community detection method based on a modified version of particle swarm optimization, named PSO-Net is proposed. PSO-Net selects the modularity Q as the fitness function which is a suitable quality measure. Our innovation in PSO algorithm is changing the moving strategy of particles. Here, the particles take part in crossover operation with their personal bests and the global best. Then, in order to avoid falling into the local optimum, a mutation operation is performed. Experiments on synthetic and real-world networks confirm a significant improvement in terms of convergence speed with higher modularity in comparison with recent similar approaches.