While cooling occurs when the oil is in the sump, cooling also occurs in other parts of the engine as well. The main purpose of oil is to lubricate, which reduces friction in the engine (other things oil does is cool, clean, protect, and cushion). Friction creates heat. Oil reduces the friction by giving two metal surfaces something to slide over so they are not in contact. This means oil gets everywhere inside the engine (where it's supposed to be, anyway ... shouldn't get in those pesky coolant passages :o). After an engine starts, the temperature of everything gets where it needs to be. The coolant temperature gets (depending on the vehicle) to around 195-210°F. This is mainly the coolant temperature. The metal around the engine can get hotter than this (depending on where it's at in the engine). The oil will also get hotter than this as well. During normal engine operation, oil should stay in the 230-260°F range. This is a lot higher than the cooling system. As oil travels through the engine to reach the sump, it's going to go over areas which are cooler than this, so the oil will give up heat as it flows over. Once inside the sump, it doesn't stay there long, but does give up heat through the sump pan. Many auto manufacturers now use aluminum pans to give the engine better overall support. Aluminum is also a great conductor of heat, which means it helps dissipate the heat in the oil through transference and radiation.
One of the reasons the oil is engineered to run hotter than the coolant is because during the combustion process, a lot of water is created from burning fossil fuels. Some of this gets into the oil. If the oil were not to get hot enough, the water would stay in the oil which would create certain acids, which would aid in the destruction of the engine internals. By running hotter than the boiling point of water, water will evaporate out of the oil and be on its merry way. This is why it's important to have vehicles out on a longer ride if it is only used to going on short trips all the time. Anything longer than 20-30 minutes worth of driving should be more than enough to get the water out.
In your question you wonder if:
... wouldn't driving for a long time (let's say 8 hours) cause it to only get hotter and hotter?
The engine stays at a certain temperature because of the cooling system (as long as it's functioning correctly). This temperature is set by the engineers of the manufacturer. Because the engine itself runs at a much lower temperature than does the oil, heat transference occurs from the oil to the cooler parts of the engine. (I realize I'm sort of restating what I said above.) This brings the temperature of the oil down and the heat goes out through the cooling system as well as through the walls of the sump. The heat doesn't just collect and stay in the oil. There would be other issues if it did!