Observations conducted using the Atacama Large Millimeter/submillimeter Array on the protoplanetary disk around TW Hya show the nitrogen fractionation of HCN molecules in HC$^{14}$N/HC$^{15}$N $sim$120 at a radius of $sim$20 AU. In this study, we investigated the physical and chemical conditions that control this nitrogen fractionation process. To this end, a new disk model was developed, in which the isotope-selective photodissociation of N$_2$ and isotope-exchange chemical reactions have been incorporated. Our model can successfully reproduce the observed HCN column density when the elemental abundances of the gas-phase carbon and oxygen are depleted by two orders of magnitude relative to those in the interstellar medium and carbon is more abundant than oxygen ([C/O]$_{rm elem}>$ 1). The isotope-selective photodissociation of N$_2$ is the dominant nitrogen fractionation process in our models. The observed HC$^{14}$N/HC$^{15}$N ratio, which increases outwards, can also be reproduced by the model by assuming that the small dust grains in the atmosphere of the outer disk are depleted more than those in the inner disk. This is consistent with grain evolution models, according to which small dust grains are continuously replenished in the inner disk due to fragmentation of the large dust grains that radially drift from the outer disk.