Jesus DOES say this in OTHER parts of the Gospel which is repeated throughout the New Testament.
The parts of Christendom that hold to a free will preponderant theology tend to propound Jesus’ sheep/goats prophecy in the manner as above.
If one takes salvation by faith as a controlling principle, however, that casts the prophecy in quite a different light. The sheep would represent those who were saved. They are rewarded for the smallest good work. (They have been pardoned of all their evil works.) The goats would represent those who remained damned. They are punished for the smallest evil work.