The Internal Revenue Service has agreed to help homeland security officials find immigrants they are trying to deport, according to court records, committing to sharing information in what would be a fundamental change in how the tax collector uses its tightly regulated records.