Alignment of optomechanical components is important when designing and manufacturing optical systems. This study used an optical fiber as a case study to develop an alignment method. The core diameter of a single-mode fiber is about 9 µm, and any slight misalignment or deformation of the optical mechanism will cause significant optical losses in connections. Previous studies have shown that the currently used alignment methods are not efficient, and the precise position for the connection is not easy to locate. This study proposes a two-stage method to overcome these problems. In the first stage, the Nelder-Mead simplex method is used to move quickly to the optimum solution. In the second stage, a numerical optimization method is used to improve the accuracy. This study compares different numerical optimization method that can be used to find the ideal connection position. It can be concluded that the most stable method for the search direction is the steepest-descent method, because the light intensity distribution is similar to a Gaussian one, and the most efficient method for the step-size determination is polynomial interpolation. Therefore, the second stage uses the steepest-descent method with polynomial interpolation.