We consider the problem of portfolio selection with risk factors, where the goal is to select the portfolio position that minimizes the value at risk (VaR) of the expected portfolio loss. The problem is computationally challenging due to the nested structure caused by the risk measure VaR of the conditional expectation, along with the optimization over a discrete and finite solution space. We develop a nested simulation optimization approach to solve this problem. In the outer layer, we adapt the optimal computing budget allocation (OCBA) approach to sequentially allocate the simulation budget of the outer-layer to different portfolio positions. In the inner layer, we propose a new sequential procedure to efficiently estimate the VaR of the expected loss. We present a numerical example that shows that our approach achieves a higher probability of correct selection under the same computing budget compared to three other methods.