Costa scored the first after 21 minutes and then laid on the second for Renato Augusto 12 minutes into the second half. Filipe Luis grabbed a third in 76 minutes after the keeper parried Costa's ferocious drive from the right wing.
"It was very important to win after the draw in Argentina and we did well," said Luis, who scored his first international goal. "The team is growing and getting better every game and we are finding a style of play that we want."
Brazil, who made three changes from the side that were fortunate to draw 1-1 with Argentina in Buenos Aires on Nov. 13, made a shaky start to the game.
Peru's Paolo Guerrero should have done better when he only had the goalkeeper to beat after just three minutes but goalkeeper Alisson got down well to smother his shot.
Brazil, however, opened the scoring after 21 minutes when Douglas Costa got on the end of a cross from Willian to bundle the ball home from close range.