I heard Allah's Messenger (ﷺ) saying this. The rest of the hadith is the same concerning 'azl and ghila (cohabitating with a suckling woman), but with a slight variation of words.
Sahih Muslim Book 16, Hadith 168