Firmino, who had made key contributions from the bench in both of his country's previous fixtures, saw his countrymen reach the last 16 by topping Group E as Paulinho and Thiago Silva netted.
Grujic's compatriots needed a victory to reach the next round of the competition, but saw their campaign ended by the five-time winners in Moscow.
Next up for Firmino and co is a meeting with Mexico, who finished second in Group F, behind Sweden.