When applying for a postdoc, the contact person is not the professor I want to work with, what shall I do?
It's simple: follow the instructions. If the contact email address is of prof. B, then you should address him in the greeting.

Do not make assumptions such as prof. B is recruiting postdoc for prof. A, or at least you should not bring this assumption to your conversation with prof. B, even if your assumption is correct. Many people may take it as disrespect.