The loss also means Swiatek's stay at No. 1 in the WTA rankings will end next week, when current No. 2 Aryna Sabalenka will rise to the top spot for the first time.
"I don't know why I played that bad," Swiatek said. "I'm not happy with my performances on hard courts this year. But overall, I did a pretty good job at maintaining my level. I'm happy I'm going to have time to practice because I miss that."
Swiatek's shots were off target in Arthur Ashe Stadium, and she had a difficult time handling the hard hitting from the 20th-seeded Ostapenko, who won the 2017 French Open.
"I knew I have to play my game," Ostapenko said after accumulating 31 winners to 18 for Swiatek. "I knew I have to be aggressive, because that's what she doesn't really like."
This was not necessarily a huge surprise, based on their previous matchups: Ostapenko has now improved to 4-0 against Swiatek over their careers. No other player owns four victories against the woman who has led the WTA rankings since April 2022.
"I was just thinking that I have to play until the very last point, until we shake hands," Ostapenko said. "I didn't really give her many chances."
After getting off to a terrific start in the second set, which she led 4-1, Ostapenko wavered for a bit. That allowed Swiatek to get a break back and pull within 4-3. But that was only a blip.
"I think the main thing is she doesn't really like to play big hitters," Ostapenko said. "She likes to have some time. When I play fast, aggressive and powerful, she's a little bit in trouble."
With Swiatek having trouble serving -- perhaps owing to all of the squeaking Ostapenko's shoes did as she moved around during the ball toss while waiting to return -- the contest quickly tilted in one direction. Ostapenko reeled off seven consecutive games to go up 5-0 in the third set.
Ostapenko broke one last time to end it, meaning she won seven of Swiatek's 13 service games in the match.
Ostapenko and Gauff have split two previous meetings. The most recent came in the fourth round of the Australian Open in January, and Ostapenko won that one.
"She's a great young player," Ostapenko said about Gauff. "Of course it's going to be another tough match. I don't expect any easy matches at a Grand Slam."
Swiatek's loss comes less than a week after she opened the tournament with a dominant performance, defeating unseeded Rebecca Peterson of Sweden 6-0, 6-1 last Monday. But she did mention after that win that she felt her tank was "pretty empty" after losing in the Montreal and Cincinnati semifinals in August.
"I feel like I'm progressing as a player, but I have more skills," Swiatek said, summing up her season. "This season was tough and intense."
The Associated Press contributed to this report.