Tottenham Hotspur midfielder Paulinho helped Brazil progress from Group A to reach the last 16 of the World Cup.
Paulinho started the game for the Selecao but was withdrawn at half-time, with Manchester City midfielder Fernandinho replacing him.
Brazil went ahead when Neymar side-footed home but Cameroon levelled against the run of play through Joel Matip.
Neymar then put Brazil back in front, driving through the Cameroon defence and drilling past Charles Itandje.
Four minutes after the break, Fred headed home his first goal of the tournament to make it 3-1 and with six minutes remaining, Fernandinho rounded off the win.
Brazil will face Group B runners-up Chile in the round of 16.