That is not correct because "whales" is plural and "mammal" is singular. They must match. The sentence should be:
"Whales are mammals that live in the ocean."
Note also the use of "the" in that sentence. It has the function of making "ocean" generalized. Although "in oceans" is not grammatically incorrect, it is far less common, because it can imply that either whales migrate between oceans or different whales live in different oceans. Although this extra piece of information is factually correct, it is probably not what you are trying to communicate, and it is not a clear way to express that idea.