Epigenetics. It's the make-file for your genetic source code. Certain conditions can cause certain parts of your genetic code to be uncommented or commented-out within any given cell or set of cells. There are actually a number of different kinds of 'comments' (histone modifications [1]) - each set of marks are particular to a different compiler, in different contexts. And these comments/marks are copied with some fidelity to daughter-cells/children along with a high-fidelty copy of the underlying genetic code itself.
So the genes (DNA) themselves are not being heritably altered, rather the recipe for which gene is produced, when, and where can be subtly changed. But again, the same mechanisms that permit the change in expression of those genes during a lifetime (of an organism, or a cell) can be subsequently changed in the next just as easily.
In this way you can store the code for some trait or capability over many generations without having it always be running. It can manifest itself in individual organisms or cells as having very different phenotypes even while possessing the same underlying genetic code.