Germ cells differentiate into oocytes that become totipotent upon fertilization. How the highly specialized oocyte acquires this distinct cell fate is poorly understood. During Drosophila oogenesis, H3K9me3 histone methyltransferase SETDB1 translocates from the cytoplasm to the nucleus of germ cells concurrent with oocyte specification. Here, we discovered that nuclear SETDB1 is required to silence a cohort of differentiation-promoting genes by mediating their heterochromatinization. Intriguingly, SETDB1 is also required for the upregulation of 18 of the ~30 nucleoporins (Nups) that comprise the nucleopore complex (NPC). NPCs in turn anchor SETDB1-dependent heterochromatin at the nuclear periphery to maintain H3K9me3 and gene silencing in the egg chambers. Aberrant gene expression due to loss of SETDB1 or Nups results in loss of oocyte identity, cell death and sterility. Thus, a feedback loop between heterochromatin and NPCs promotes transcriptional reprogramming at the onset of oocyte specification that is critical to establish oocyte identity.