Some commentators focus all their attention on the words, “head of the bed”: Rashbam, for example, says it simply indicates where Jacob was lying. The Septuagint changes mittah (bed) to matteh (staff), but this is unjustifiable and most scholars reject it.
The clue probably resides in the words “he bowed”, which Rashi takes metaphorically: “He turned to the Divine Presence”. From this the sages deduce that God is above the pillow of a sick person (Shab. 12b).
Others (e.g. Ibn Ezra) suggest that Jacob was showing deference to Joseph, not necessarily because his beloved son was the Egyptian viceroy, but because temptation had not turned him away from righteousness.
Jacob realised how easy it was to compromise one’s standards because he himself had faced the same problem whilst living in Laban’s house, hence the rabbinic rhyme, Im Lavan garti, v’taryag mitzvot shamarti – “I lived with Laban, but (still) I kept the commandments”.