Per IRS Publication 17 Your Federal Income Tax (For Individuals), page 146:
You generally can include medical expenses you pay for yourself, as well as those you pay for someone who was your spouse or your dependent either when the services were provided or when you paid for them. There are different rules for decedents and for individuals who are the subject of multiple support agreements. See Support claimed under a multiple support agreement, later.
You can include medical expenses you paid for your spouse. To include these expenses, you must have been married either at the time your spouse received the medical services or at the time you paid the medical expenses.
Example 1. Mary received medical treatment before she married Bill. Bill paid for the treatment after they married. Bill can include these expenses in figuring his medical expense deduction even if Bill and Mary file separate returns.
If Mary had paid the expenses, Bill couldn't include Mary's expenses on his separate return. Mary would include the amounts she paid during the year on her separate return. If they filed a joint return, the medical expenses both paid during the year would be used to figure their medical expense deduction.
Example 2. This year, John paid medical expenses for his wife Louise, who died last year. John married Belle this year and they file a joint return. Because John was married to Louise when she received the medical services, he can include those expenses in figuring his medical expense deduction for this year.
For more information, see IRS Publication 17.
To enter your medical expenses in TaxAct®: