You can deduct mortgage interest on a second home as an itemized deduction if it meets all the requirements for deducting mortgage interest.
If you rent out your second home, you must also use it as a home during the year. You must use it more than 14 days or more than 10% of the total days it is rented out, whichever is longer. If you don't use the home long enough, it's considered a rental property. You can then deduct the mortgage interest as a rental expense.
Mortgage interest can only be claimed on a maximum of two homes (main home and a second home).