The Tur wrote that it is permitted to rent out one's oven to a non-Jew on the condition that he bake matzah in it. And even if he baked chametz in it—he is not concerned with him, and he may take his payment. And even though regarding wine used for idolatry it is not so, for if he hired him to perform another task with him, and he performed it with wine used for idolatry—his payment is forbidden, as I wrote in Yoreh Deah siman 133; for there, if he had not performed the task he would not have taken anything, therefore when he takes payment—he takes the payment of wine used for idolatry. This is not the case with an oven for a day or for a week, for even if he does not bake in it at all—he is obligated to pay his rent. If so, what do we care that he baked chametz, since he stipulated with him for matzah (Magen Avraham subsection 5). Therefore, if indeed the condition was explicit, that when he bakes he shall pay, and if he does not bake he shall not pay—it is forbidden. And one should not ask that still, what does the condition avail, for are we not witnesses that he will certainly bake chametz in it, as above in siman 246? For a condition does not avail to rent out one's horse on the condition that it rest on Shabbat, because it certainly will not rest, and if so, here too it is so. And there is one who raised this difficulty (Taz subsection 4). However, this is not a comparison, for there he is commanded regarding the resting of his animal, and since it is known that it will not rest—it is forbidden. This is not the case here, for he is not commanded regarding the resting of the oven from chametz, but only that he should not benefit from the chametz. And since he rents him his oven not for the sake of chametz but in a general sense, he is not taking the payment of chametz (Chok Yaakov subsection 8). And all the more so when he says explicitly: on the condition that he bake in it something that is not chametz.
כתב הטור דמותר להשכיר תנורו לאינו יהודי על מנת לאפות בו מצה. ואפילו אם אפה בו חמץ – אינו זקוק לו, ונוטל שכרו. ואף על גב דביין נסך אינו כן, דאם שכרו לעשות עמו מלאכה אחרת, ועשה עמו ביין נסך – שכרו אסור, כמו שכתבתי ביורה דעה סימן קלג; דהתם אם לא היה עושה המלאכה לא היה נוטל כלום, לפיכך כשנוטל – נוטל שכר יין נסך. מה שאין כן בתנור ליום או לשבוע, אפילו אם לא יאפה בה כלל – מחוייב לשלם שכרו. אם כן מה איכפת לן מה שאפה חמץ, כיון שהתנה עמו על מצה (מגן אברהם סעיף קטן ה). ולכן אם באמת היה התנאי מפורש, שכאשר יאפה ישלם, ואם לא יאפה לא ישלם – אסור. ואין לשאול דאכתי מאי מהני תנאי, הא אנן סהדי שוודאי יאפה בו חמץ, כמו לעיל בסימן רמו? דלא מהני תנאי להשכיר סוסו על מנת שינוח בשבת, משום דבוודאי לא ינוח, ואם כן הכא נמי כן הוא. ויש מי שהקשה כן (ט"ז סעיף קטן ד). אמנם אין זה דמיון, דהתם מצווה על שביתת בהמתו, וכיון שידוע שלא תשבות – אסור. מה שאין כן הכא, אינו מצווה על שביתת התנור מחמץ, אלא שהוא לא יהנה מהחמץ. וכיון שמשכיר לו תנורו לא בשביל חמץ אלא בסתם, הרי אינו נוטל שכר חמץ (ח"י סעיף קטן ח). וכל שכן כשאומר בפירוש על מנת שיאפה בו דבר שאינו חמץ.