Are both expressions correct? If yes, do they have different meanings? It seems to me that I came across both of them in books, but I'm not sure.
They are both correct, but convey slightly different ideas.
Implies that I will sleep on the piece of furniture I refer to as a bed. As opposed to sleeping on the couch or sleeping on the floor.
Specifically conveys the idea that I will be inside the bedclothes, typically underneath a blanket or duvet.
Both expressions are correct and can have different meanings. A bed usually is made of a surface for sleeping upon and a warm cover of some kind. The phrase on the bed would be taken to imply that something is placed upon both. Take this example:
This would mean the luggage was placed upon the top of the upper surface of the bed and bedding.
The phrase in the bed would be taken that something is placed between the warm covering (or bed cover) and above the sleeping surface. It is placed inside the bed, as illustrated by this example:
If the hot water bottle was placed on the bed it would get cold and not warm the bed properly.
Thus if we use sleep as the action being performed, you can see that we can both sleep in the bed and sleep on the bed. For example:
There is a very famous bed in event which can also be used to illustrate the difference:
This is John and Yoko on the bed:
This is John and Yoko in the bed:
Sleeping in the bed would actually mean to be inside the bed(covered by under the sheets") however, Sleeping on the bed logically mean laying on the bed on the surface of it, don't go deep into the holy crap of English literature.