The 40-year-old Bartolo Colon will also be a part of next week's festivities.
After going 1-6 with a 6.36 ERA in his first two major league seasons, Locke (8-1, 2.12 ERA) has come out of nowhere to post baseball's second-lowest ERA. The 25-year-old left-hander, whose only loss came at Dodger Stadium in his season debut April 7, will join teammates Andrew McCutchen, Pedro Alvarez and Jason Grilli at the Midsummer Classic.
"I was totally surprised. And felt honored. It's something they can't take away from you," Locke, who yielded three runs in 5 2-3 innings Wednesday in a 6-5 win over Philadelphia, told MLB's official website.
"It goes beyond the numbers; the confidence level is something I did not have before. I got a little edge on the mound."
Colon (11-3, 2.78), meanwhile, was the only Athletics player to make the AL squad. The 16-year veteran has two prior All-Star appearances, coming in 1998 and 2005.
"I feel extremely happy about it," he said through coach and interpreter Ariel Prieto. "I believe it's all about the work that I've been doing, since even before the season started. I thank the Oakland A's for giving me the opportunity to be part of them."
Colon had posted a 1.37 ERA in winning a career-high eight consecutive starts before allowing two runs in seven innings Wednesday in a 3-1 loss to the Chicago Cubs. He is 2-1 with a 1.50 ERA in four starts against the Pirates (53-34), but hasn't faced them since 2007.
The Athletics (52-37) have had their way with Pittsburgh, taking all nine matchups in the series by a 65-28 margin. Oakland's only previous visit to PNC Park came in 2002.
Sitting one-half game ahead of Texas in the AL West, the A's are coming off their eighth win in 11 games, 10-4 at Kansas City on Sunday. Josh Reddick, Jed Lowrie and Eric Sogard all homered, going a combined 7 for 14 with nine RBIs.
"It's nice to make the All-Star team and everything, but at the same time we're a big family here and we have our eyes set on the goal of the Fall Classic rather than the Midsummer Classic," winning pitcher A.J. Griffin said. "We're just trying to continue to play good baseball as a team and not worry about stuff like that."
The Pirates are tied with St. Louis for the NL's best record, but they are looking to avoid a fifth loss in seven games after falling 4-3 in 11 innings at Wrigley Field on Sunday. Starling Marte hit a game-tying homer in the ninth before Pittsburgh came undone in the 11th following Russell Martin's first error of the season.
"We're playing to win," manager Clint Hurdle said, "and if you've watched that guy play all year … You just move on."
While Pittsburgh has outscored opponents 41-21 during an eight-game winning streak in interleague play, the A's are 20-7 versus NL foes dating to last June.
Oakland will need to be wary of Alvarez, who is hitting .333 with eight homers and 19 RBIs in his last 19 games. He is also batting .389 with five homers and eight RBIs in his last 10 interleague contests.