When, if ever, does it make sense to borrow from a 401(k)? In a word: never. Your retirement funds are like a long-term savings account to support you into your golden years when you are no longer working. This money should be completely off-limits, in my opinion.
The only possible reason you should borrow from your 401(k) is a dire emergency, you have exhausted all other possible resources and you have no additional funds of your own. Otherwise, aside from continuing to invest in your 401(k), you should leave it completely alone.