The decline of wagons was very gradual. They were displaced for long-distance movement of bulk goods starting in the 1820s and 1830s by the canal building frenzy sparked by the success of the Erie Canal. Canals were the cheapest way to ship bulk goods for a long time.
By the 1840s, ocean-faring steamboats provided direct competition to wagons for transcontinental passenger transportation. During the 1849 Gold Rush, the majority of migrants traveled to California by steamer, a trip which was made faster by the Panama railway in 1855. Cornelius Vanderbilt made a killing with his Accessory Transit Company, which carried some 2,000 passengers each month by steamboat from the East Coast, through the waters of Nicaragua, and finally on to California. It was among the cheapest ways to reach California.
Wagons took a further hit with the extension of railroads into the West. Wagon traffic on the Oregon Trail began to decline after 1869, with the completion of the first transcontinental. The Santa Fe Trail hung on longer, until the railroad reached Santa Fe in 1880.
In short, wagons were less efficient than other modes of transportation, and so they were used wherever canals, railroads, and steamboats didn't reach. Isolated farmers would still be using wagons to get their goods to market until motor trucks displaced them once and for all.