Transposable elements (TEs) are implicated in a variety of processes including placental and preimplantation development and a variety of human diseases. TEs are known to be activated in the context of viral infections, but the mechanisms and consequences are not understood. We show strong activation of TEs upon DNA virus infection, in particular the MLT- and THE1-class of LTR-containing retrotransposons as well as a subset of LINE-1-, Aluelements and HERVs. Mechanistically, two pathways induce TE upregulation: inhibition of the KAP1/TRIM28 repressive complex by phosphorylation, and expression of the pioneer factor double-homeobox 4 (DUX4), which is known to be crucial for TE induction during zygotic genome activation in embryonic development. In adults, DUX4 is usually silenced and we showed DUX4 expression upon infection with various DNA viruses. DUX4 binds to TEs upon infection and analysis of genes adjacent to TEs shows pathways that are important for DNA virus infections. Analysis of knockdown, knockout and overexpression data reveal that almost all TEs expressed upon herpesviral infection are regulated by KAP1/TRIM28 and DUX4. Interestingly, analysis of single cell sequencing data from patients with DNA virus-associated cancers showed that in vivo TE expression strongly correlates with virus infection, indicating a possible role in viral oncogenesis.