Ramanujan may have been aware of 1728 == 12² because of 12's recurrence within number theory. (Well, really, 24's recurrence. [1]) He wrote down several equations [2] which feature 12 and 24, and given the time in which he lived, he may have been acquainted with the work of Felix Klein and others [3] as well.
The other sum is 1000 + 729, much easier for a decimal-preferring mentat like Ramanujan to pull from thin air.
[1] http://math.ucr.edu/home/baez/numbers/