From the regs. Refinancing does not qualify as a principal residence loan. Prior Q&A also states requirement that loan is used to acquire the principal residence.
Q–8: Can a refinancing qualify as a principal residence plan loan?
A–8: (a) Refinancings. In general, no, a refinancing cannot qualify as a principal residence plan loan. However, a loan from a qualified employer plan used to repay a loan from a third party will qualify as a principal residence plan loan if the plan loan qualifies as a principal residence plan loan without regard to the loan from the third party.
(b) Example. The following example illustrates the rules in paragraph (a) of this Q&A–8 and is based upon the assumptions described in the introductory text of this section:
Example.
(i) On July 1, 2003, a participant requests a $50,000 plan loan to be repaid in level monthly installments over 15 years. On August 1, 2003, the participant acquires a principal residence and pays a portion of the purchase price with a $50,000 bank loan. On September 1, 2003, the plan loans $50,000 to the participant, which the participant uses to pay the bank loan.
(ii) Because the plan loan satisfies the requirements to qualify as a principal residence plan loan (taking into account the tracing rules of section 163(h)(3)(B)), the plan loan qualifies for the exception in section 72(p)(2)(B)(ii).