I've always wondered about this as well. I've heard people say just test it by swimming in the water, but that seems rather unscientific.
I'm conservative when it comes to safety gear so tend to replace if I'm not sure. I replaced a PFD a few years ago and noticed that the new (exact same kind) was noticeably fatter, i.e. less compressed, than my old one, so seemed like a good call.
Then I just recently replaced another one (exact same kind) because it was a few years old and showed significant fading, but when I put them side by side, the foam actually looked pretty similar so maybe it was premature.
I always figure I should use my old one for playboating and such and newer one for more important applications to spread the wear, but rarely succeed in actually doing that.