In proof of work, when a fork occurs in the blockchain, nodes trust the fork that has the most computational work put into it. How do proof of stake nodes know what chain to trust?
Your question might be rephrased as follow: What is the fork choice rule of Ethereum proof-of-stake?
As a reminder:
A fork choice rule is a function, evaluated by the client, that takes as input the set of blocks and other messages that have been produced, and outputs to the client what the “canonical chain” is.
I cannot give a general explanation of PoW or PoS fork choice rule. It is due to the fact that each blockchain can have its own rule to handle forks. So when asking about fork choice rule make sure to specify which blockchain you're refering to. Let's see a few of them to answer your question.
For Bitcoin, the fork choice rule is the longest chain rule.
You gave the fork choice rule of Ethereum PoW:
nodes trust the fork that has the most computational work put into it.
In there own words:
If the total difficulty is higher than our known, add it to the canonical chain
- For Ethereum PoS, the fork choice rule is called LMD GHOST (latest message-driven greedy heaviest observed sub-tree) and works as follow: the canonical chain is the chain with the most attestation on it. When counting the attestaion, we count only one attestation by validator and it is its latest one (LMD part).
If you want more details on how it work exactly, you can look at the specifications.