If you don't know the value of sigma (population standard deviation), then you must use the T distribution instead of the Z distribution. However, if the sample size n is greater than 30, then the T distribution is approximately the same as the Z distribution.
This means that even if you don't know sigma, you can use the Z distribution if n > 30.
-----------------------------------
In short, you use T over Z if you don't know sigma and n = 30 or smaller