Training through research should be the main activity during an IF. The H2020 Annotaded Grant Agreement/Model Grant Agreement states (in several places) that the recruited researchers must be working exclusively for the action / must work exclusively on the research training activities. However, typical training activities in Ifs may include, e.g., ‘supervising and monitoring’ (GfA 2015, p. 13) which is already quite similar to teaching. Acquiring good competencies in teaching is also necessary for a professorship or any other next career step. Additionally, the GF focus on Transfer of Knowledge, and teaching a class would be an excellent means of Transfer of Knowledge.
So it is not excluded, but has to remain within a reasonable expenditure of time and correspond to the overall aim of the IFs, namely the career advancement of the researcher.
But extra work is NOT allowed, researchers should work full-time on the project and concentrate on it.