The NFL announced Foster's suspension Tuesday, which will keep him off the field for San Francisco's first two regular-season games.
Per the league's official statement, Foster's punishment was handed down for a "weapons offense and a misdemeanor drug offense, both of which were resolved earlier this year."
Foster was arrested on Feb. 11 in Santa Clara County on charges of domestic violence, threats and possession of an assault weapon. It was the 24-year-old's second arrest in less than a month after being charged with marijuana possession in Alabama on Jan. 12.
Robert Salonga of the Mercury News reported Foster's girlfriend Elissa Ennis accused him of physically dragging her during an argument at their house in Los Gatos. The domestic violence charge was later dropped after Ennis recanted her story and the judge dismissed the charge for lack of evidence.
The 49ers drafted Foster 31st overall in 2017. He started 10 games as a rookie, leading the team with seven tackles for loss and finishing second with 72 total tackles.
Foster will be eligible to return for San Francisco's Week 3 game against the Kansas City Chiefs on Sept. 23.