Episodic accretion in magnetically layered protoplanetary discs