Aiming at the tool position optimization problems in flank milling of non-developable ruled surface with conical tools, a new method based on immune particle swarm optimization (IPSO) and least squares (LS) is proposed. The geometric features of the non-developable ruled surface are analyzed and the error measurement function under each tool position is used as the objective function of the intelligent algorithm. It means that the sum of the distances from the discrete points on the axis of the conical tool to the design surface is the minimum by adjusting the cutter axis and the offset distance to the design surface. The initial tool position is determined by two-point offset method. On this basis, the objective function is optimized by the immune particle swarm optimization algorithm to obtain the optimized tool position. Since the geometric decomposition method is adopted, the optimization is essentially a local optimization, so the least squares method is further used for global optimization, and the overall optimized tool position is obtained. The simulation results show that the machining error is reduced by 86% and the validity of the method is verified by machining experiments finally.