The saying "no man can serve two masters" is from Matthew 6:24, spoken by Jesus in the Sermon on the Mount.
No man can serve two masters: for either he will hate the one, and love the other; or else he will hold to the one, and despise the other. Ye cannot serve God and mammon.
The verse itself supplies the sense: a servant cannot hold to two masters at once, so a person cannot serve both God and mammon (see What is mammon in the Bible?). Full chapter: Matthew 6.