Here are some tips from the Internal Revenue Service:
It is mandatory for your move to be linked to the start of a new job. Moving expenses are eligible up to one year from the date you begin working at a new job location. There may be more rules depending on your situation, so check the IRS website.
Your planned move must pass a “distance test.” If you don’t like tests, you’re out of luck. Know that the primary location of your new main job must be at least 50 miles farther from your old home than your previous job location.
Says the IRS, “For example, if your old job was three miles from your old home, your new job must be at least 53 miles from your old home.”
There is another test that must be passed: the “time test.” Once you move, you are required to work full-time at your new job for at least 39 weeks the first year, says the IRS. If you are a business owner, you are required to pass this test and work full-time for a minimum of 78 weeks during the first two years at the new job location.
For more information, see IRS Publication 521, Moving Expenses.