Epigenetic variation has been observed in a range of organisms, leading to questions of the adaptive significance of this variation. In this study, we present a model to explore the ecological and genetic conditions that select for epigenetic regulation. We find that the rate of temporal environmental change is a key factor controlling the features of this evolution. When the environment fluctuates rapidly between states with different phenotypic optima, epigenetic regulation may evolve but we expect to observe low transgenerational inheritance of epigenetic states, whereas when this fluctuation occurs over longer time scales, regulation may evolve to generate epigenetic states that are inherited faithfully for many generations. In all cases, the underlying genetic variation at the epigenetically regulated locus is a crucial factor determining the range of conditions that allow for evolution of epigenetic mechanisms.