Be in the doghouse

Be in the doghouse
Be out of favor with someone

Essere nei guai con qualcuno 
Essere in disgrazia / Essere nella merda (Volg.)
Be out of favor with someone

Essere nei guai con qualcuno 
Essere in disgrazia / Essere nella merda (Volg.)
Meanings
Fig.: this phrase means to be in trouble, in an uncomfortable situation, in a state of disgrace with someone.
Examples
“How come you are sleeping on the sofa? What happened?” “Well, I'm in the doghouse. Last week I came home drunk and I forgot our wedding anniversary. Once again!”
Come mai dormi sul divano? Che cosa è successo?". "Beh, sono nei guai
con mia moglie. La settimana scorsa sono tornato a casa ubriaco e, per
di più, ho dimenticato il nostro anniversario di matrimonio. Ancora una
volta!"
He's really in the doghouse at work! They found out that he called in sick but he actually went hunting. I'm afraid there's a pink slip in sight…
È davvero nella merda al lavoro! Hanno scoperto che si è dato malato, ma
che, in realtà, è andato a caccia. Temo che ci sia un licenziamento in
vista...
I'm afraid that my brother and I are really in the doghouse, since we've been grounded over nothing: we were simply playing ball in the living room when the ball knocked over the floor lamp and smashed one of mom's beloved vases, before breaking the window…
Temo che io e mio fratello siamo davvero nei guai, visto che siamo stati
messi in punizione per niente: stavamo semplicemente giocando a palla
in soggiorno quando la palla ha rovesciato la lampada da terra che ha
mandato in frantumi uno dei vasi preferiti di mamma, prima di rompere la
finestra...Origin
The most natural interpretation of this saying is that it refers to punishing a dog, by sending him outdoor to his doghouse. However, in a metaphorical sense, it indicates that someone is not pleased with you, most likely due to something you did, and this person thinks you should sleep outside with the dog.
There is, though, a more complex hypothesis, which dates back to the days of slave trading.
The holds of ships carrying human cargo from Africa to the USA were modified to become enormous dormitories. This left little if any room below deck for crew members to sleep. This was solved by building kennel style huts (dog houses) on the deck for sailors to use as bunks. Of course sleeping on the upper deck in these hot humid and somewhat air-free hutches was very unpleasant (harbourguides.com).