Did the Church ever teach that sex during pregnancy is a sin? I know some Church Fathers like Augustine taught this.
It is true that St. Augustine spoke harshly against a husband who would approach his wife for sexual intercourse while she was pregnant (see Of the Good of Marriage, 5). But the Church is more humane in its magisterial teaching.
For example, Pope Pius XI stated in Casti Connubii:
Nor are those considered as acting against nature who in the married state use their right in the proper manner although on account of natural reasons either of time or of certain defects, new life cannot be brought forth. For in matrimony as well as in the use of the matrimonial rights there are also secondary ends, such as mutual aid, the cultivating of mutual love, and the quieting of concupiscence which husband and wife are not forbidden to consider so long as they are subordinated to the primary end and so long as the intrinsic nature of the act is preserved (sec. 59; emphasis added).
Pope Pius XII stated the following in a 1951 allocution to midwives:
It is necessary first of all to consider two hypotheses. If the application of that theory implies that husband and wife may use their matrimonial right even during the days of natural sterility no objection can be made. In this case they do not hinder or jeopardize in any way the consummation of the natural act and its ulterior natural consequences (emphasis added).
Just as when sexual intercourse occurs during the infertile period of the woman’s cycle, the sexual act during pregnancy still retains its intrinsic ordination to the procreative end—that’s to say, the act itself is still directed to the procreative end, even though natural circumstances prohibit the achievement of that end. There is nothing done to intentionally frustrate the sexual act. Therefore, it is morally licit.