It is speculated that the accretion of material onto young protostars is episodic. We present a computational method to include the effects of episodic accretion in radiation hydrodynamic simulations of star formation. We find that during accretion events protostars are switched on, heating and stabilising the discs around them. However, these events typically last only a few hundred years, whereas the intervals in between them may last for a few thousand years. During these intervals the protostars are effectively switched off, allowing gravitational instabilities to develop in their discs and induce fragmentation. Thus, episodic accretion promotes disc frag- mentation, enabling the formation of low-mass stars, brown dwarfs and planetary-mass objects. The frequency and the duration of episodic accretion events may be responsible for the low-mass end of the IMF, i.e. for more than 60% of all stars.