When to use t-distribution instead of normal distribution?
Student t-distribution by definition is a distribution of mean estimates from samples taken from the normally distributed population.

T-distribution has thicker tails and it gets thinner with increase of degrees of freedom, which in turn depends on sample distribution. So, at some point it closely resembles normal distribution and can be substituted by it.

As far as I remember (although, not 100% sure) this sample size of 30 threshold is valid for the t-test with α=0.05 (widely accepted Type I error level). Although, of you have much smaller α (e.g. 0.0001) you need to go much further to the tails of the distributions where the difference between t-distribution and normal distribution will be much more evident and thus you are better off using t rather than normal for larger sample size.

Another issue is standard deviation (or rather here we are talking about standard error). Normal distribution (and thus z-test) requires knowledge of population standard deviation. If you do not know it, you need to estimate it from the sample and it is obviously will be only an estimation of the population standard deviation. Student t-distribution handles estimated standard deviation better because using it with normal distribution (which should have only population standard deviation) will create extra errors (you will incorrectly estimate your type I (and Ii) errors).

So, the answer is, if you do not know population mean (which is almost always the case in the real world), use t-distribution. If you know population mean, be careful with 30 sample threshold. Depends on your application it can be significantly higher.