A word for when you speak ill of something and it turns out the person you are speaking to likes that thing
Not a word, but a phrase; put your foot in it/your mouth, also known as Foot-in-Mouth disease which plays on Foot-and-Mouth disease, an ailment which afflicts cattle.
Example
I was talking to the boss about the new XYZ and I really put my foot in it, I didn't know he'd just bought one of the hideous things!
A good phrase would be faux pas
a slip or blunder in etiquette, manners, or conduct; an embarrassing social blunder or indiscretion.
Dictionary.com
While it's not as highly specific as your scenario I believe it would still fall under a faux pas.
I don't think English has a word for the precise situation you are after, but have you considered gaffe:
an unintentional act or remark causing embarrassment to its originator; a blunder.
synonyms: blunder, mistake, error, slip, faux pas, indiscretion, impropriety, miscalculation, gaucherie, solecis, slip-up, howler, boo-boo, fluff, flub, blooper, goof
"I made some real gaffes at work"