Say you're a few decades into your career when you receive notice that you've inherited $20,000. The only condition is that it must be saved for retirement. So what's the best way to do that? The answer depends on a combination of factors, including your income, your age and your existing savings. And that's before you even get to the point of choosing specific investments. For people in their 40s — who often have settled into a career and are in their peak earnings years — it's common to have access to a 401(k) plan or similar option through work.

Jason York | Getty Images

If you already participate, you could use some of that $20,000 windfall to max out on your contributions. And if you don't yet participate, now's the time to get started. "I've seen some 40-somethings with millions in assets, and others that are just starting to save," said certified financial planner Sophia Bera, founder of Gen Y Planning. For 2019, people under age 50 can can put up to $19,000 in their 401(k) plan. Your contributions are pre-tax, which reduces your taxable income. Remember, too, that many companies will make a matching contribution — i.e., 50 cents or $1 for each $1 you put in — up to a certain amount, which is generally viewed as free money.

I've seen some 40-somethings with millions in assets, and others that are just starting to save. Sophia Bera Founder of Gen Y Planning

If you've maxed out on those 401(k) contributions or want other tax-advantaged options, an individual retirement account could work. If you earn less than $137,000 (or $203,000 for married couples), you can put up to $6,000 into a Roth IRA for 2019. If your income is above the income limit, a Roth IRA is unavailable to you. Although Roth contributions are not tax-deductible even for those qualify, earnings grow tax-free and withdrawals are completely tax-free once you reach age 59½, as long as you've owned a Roth for at least five tax years. Be aware that while you generally can withdraw, at any time, any amount you contributed, taking out earnings before that minimum age could result in a tax penalty.