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 some 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-, Alu-elements and HERVs. Mechanistically, two key pathways induce TEs upregulation: inhibition of the KAP1/TRIM28 repressive complex by phosphorylation, and expression of the pioneer transcription factor double-homeobox 4 (DUX4), which is known to be involved in TE-induction during zygotic genome activation in embryonic development. DUX4 is induced by DNA viruses, it 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 TEs expression strongly correlates with virus infection, indicating a possible role in viral oncogenesis.