The lung allograft communicates directly with the outside environment. So, whatever is inhaled is in direct contact with the transplanted lung. It is very well understood, that the inhaled gas may contain infectious substances like bacteria, virus etc.
Now, if a person having a lung transplant, inhales some infectious agent, then that infectious agent will come into the transplanted lung. Since this lung is foreign, so, the infectious agent is completely new to the body of this patient. And the body does not have enough immune response (cellular and humoral immunity) to cope up with this foreign infectious agent. So, the immune system gets a signal that some totally new substances are there in the body; this starts production of immune cells; antibodies/complement/cellular immunity; into the body, to cope up with totally new agents. Among these new agents, the transplanted lung is also there which is ultimately rejected. This is not the case with heart transplant because the human heart is not in direct contact with the external environment.
One more important point of consideration is that during lung transplant, some air is still there in the lungs. If this transplanted lung, happens to have the virus in that air, then certainly the graft would be rejected via a viral attack. On the other hand, in a heart transplant, the heart is completely freed of air, so there are no chances of a viral or bacterial attack.