Unopened in the original packaging, you open it and look for spots or discoloration anywhere on the surface of the tofu. If there isn't anything, you sniff. If there's no odor, you can eat it.
I've eaten tofu expired for months, and I've had to throw out tofu before the expiration date because it smelled bad and had obvious bacterial colonies growing on it.