Doping behavior in quantum dots (QDs) differs from that in the bulk. Despite many efforts, the doping properties are still not fully understood. Using first-principles methods, we have calculated the formation energies of various group-III acceptors and group-V donors doping at all non-equivalent sites in a Si QD (Si147H100). To analyze the trend of the formation energy, we decompose it into two terms: the unrelaxed formation energy (chemical energy) and the relaxation energy. We find that the unrelaxed formation energy generally increases as the dopant moves from the center of the QD to the surface. The variation of the unrelaxed formation energy in the surface region is explained by the variation of the local potential of the QD and the size effect. The relaxation energy gain increases as the size mismatch between the dopant and Si atom increases. Generally, the relaxation effect becomes more significant as the dopant moves toward the surface of the QD. The trend of the formation energy is determined by the two terms discussed above. If the size mismatch between the dopant and Si atom is small, the trend of the formation energy generally follows that of the unrelaxed formation energy, increasing as the dopant moves from the center to the surface; thus, these dopants have a better chance of staying in the core region. On the other hand, if the size mismatch is large, the relaxation effect dominates and the formation energy decreases, which indicates these dopants cannot enter the core region under equilibrium growth conditions.