In a perfect world, we'd all be able to get affordable mortgages at rock-bottom interest rates when buying a home. But we don't live in a perfect world, and sometimes the only mortgage you can get is a pricey one. Fortunately, you're not stuck with it for the next 30 years: You always have the option to refinance.

Here are a few situations where you may want to consider it.

Interest rates have gone down

Mortgage rates are currently at a seven-year high and hover around 4.6%, but they're still very low, historically speaking. If you purchased a home when rates were much higher than they are now, then you could save yourself tens of thousands of dollars by refinancing.

Mature couple doing financial calculations

Image source: Getty Images.

Say you purchase a $300,000 home with 20% down and a 4.5% interest rate. That means you'd pay about $1,216 per month over a 30-year term for a total of almost $438,000. But if you decide to refinance after five years and manage to secure a 4% interest rate, you now only owe $1,044 per month. That's a savings of $172 per month, which adds up to over $2,000 per year. Now, if you only made the required monthly payment, you would end up spending a little over $450,000 when all is said and done because you paid five years at a higher interest rate and then essentially extended your loan term for another five years and paid closing costs again. But if you kept making the same $1,216 payment you made before, you would pay off the mortgage ahead of schedule and only end up spending $407,000, plus closing costs.

Refinancing can be a great way to secure a lower monthly payment, but keep in mind that you'll also have to pay closing costs again -- and unless you're shortening your mortgage term when you refinance, you'll be extending the length of time you're paying for your home, so it could end up costing you more in the long run. However, you always have the option to pay more than the minimum payment, so it may not take you the full 30 years to repay the debt. Before you refinance, it's important to crunch the numbers and make sure the savings are worth the closing costs and hassle.

Your income and credit score are higher

Lenders look at many factors when determining whether or not to approve your mortgage application. Two of the most important factors are your income and your credit score. Your credit score is essentially a measure of your financial responsibility, and it's based on how you've previously handled loans and other lines of credit.

Your income plays a role in your debt-to-income ratio, which reflects how much you owe compared to how much money you have coming in. Lenders want to make sure you're earning enough money to make your mortgage payments, and most will not lend to you if your debt-to-income ratio is higher than 43%.

High income and a high credit score can both help to increase your odds of approval and get you the best interest rates. If your credit score and/or your income has increased since you got your first mortgage, now may be a good time to refinance and see if your lender is willing to offer you a better deal.

You don't like your lender

Some mortgage lenders are not as transparent as others, and some care more about their bottom line than they do about their clients. If you're unhappy with your current lender, you can always try refinancing with a different company that has a better reputation.

But again, this may or may not be a smart move financially when you consider that you'll have to pay closing costs all over again. If you're near the end of your loan term, you may be better off just toughing it out.

Refinancing can save you quite a bit of money on your mortgage, but it's not always the right decision. Do the math and make sure the costs don't negate the savings, and always shop around to ensure that you're getting the best deal possible.