Before you can figure how much, if any, of a distribution from your pension or annuity plan is taxable, you must determine your cost (your investment in the contract) in the pension or annuity. Your total cost in the plan includes everything that you paid. It also includes amounts your employer paid that were taxable to you when paid. Cost does not include any amounts you deducted or excluded from income.
From this total cost, subtract any refunds of premiums, rebates, dividends, unrepaid loans, or other tax-free amounts you received by the later of the annuity starting date or the date on which you received your first payment.
Your annuity starting date is the later of the first day of the first period for which you received a payment, or the date the plan's obligations became fixed.taxmap/pub17/p17-052.htm#en_us_publink100032907
Your cost in these accounts is your designated Roth contributions that were included in your income as wages subject to applicable withholding requirements. taxmap/pub17/p17-052.htm#en_us_publink100032908
If you worked in a foreign country and contributions were made to your retirement plan, special rules apply in determining your cost. See Publication 575.