The Uruguayan thanked a follower using the phrase "gracias negrito," which translates to thank you, little Black one.
The phrase is seen as an affectionate term of endearment in South America but considered offensive in other parts of the world, because its meaning can be misconstrued.
Having come on as a substitute at halftime on Sunday with Manchester United 2-0 behind, Cavani had an instant impact, scoring twice and assisting the other goal to help his side to a dramatic victory.
"The message I posted after the match on Sunday was intended as an affectionate greeting to a friend, thanking him for his congratulations after the game," Cavani said in an apology on the Manchester United website. "The last thing I wanted to do was cause offence to anyone. I am completely opposed to racism and deleted the message as soon as it was explained that it can be interpreted differently. I would like to sincerely apologise for this."