When was it discovered XY chromosomes decide the sex of a child in humans?
The discovery of genetic sex determination, and determination of sex via male gametes (in XY species, female in ZW), occurred over some time in the late 1800's and early 1900's. Advances were made with methods to stain chromosomes and, in 1891, Henking noted that wasps produced sperm with a varying number of chromosomes. However, he was unable to gather evidence that the "x-element" was determining sex. Nettie Stevens, in 1905, then used beetles and noted an odd set of chromosomes in sperm, which later became known as the sex chromosomes. This was the discovery of sex determination through male gametes.


  "In 1905, while studying the gametes of the beetle Tenebrio molitor, Stevens noted an unusual-looking pair of chromosomes that separated to form sperm cells in the male beetles. Based on her comparisons of chromosome appearance in cells from male and female beetles, Stevens proposed that these accessory chromosomes were related to the inheritance of sex." - Link


In 1905, Beecher-Williams also made the same discovery, so they are both credited with discovering sex determination by the sex chromosomes. However, Clarence Erwing McClung also contributed to theory that Henkings X-elements may determine sex in 1901.

Thomas Hunt Morgan also contributed some major work on heredity and sex chromosomes, having been initially sceptical of Stevens' discovery. He found that eye mutations in Drosophila appeared to be sex linked, and concluded that the mutations were likely carried on the sex chromosomes.

There is a paper from 1910 where Michael Guyer concludes that accessory chromosomes (the sex chromosomes) likely determined sex in humans.


  "It is probable that in man and certain other vertebrates, as in the insects, myriapods and arachnids, the accessory chromosomes are in some way associated with the determination of sex."


However, Theophilus Painter, in 1921, concluded for the first time that human sex determination was by the presence of X or Y in the sperm; Guyer had gone for an XO system. While Painter got the chromosome count wrong, being hampered by the techniques of the day (an issue that wasn't resolved until the 1950's), he got the sex determination system right.