I have two groups. One has 25 observations, and the other has 240 observations. I want to test whether the two groups' means are different or not. Could you please tell me which test I should apply, the t-test or the z-test, for these two groups?
The choice between a z-test and a t-test has nothing to do with sample size. Simply, the z-test is used when the population standard deviation is known. And the t-test is used when the population standard deviation is unknown.
The idea that a z-test would be used sample sizes larger than, say, 30, is simply that z-test is a good approximation of the t-test for large sample sizes, and t value tables on paper didn't go up to large sample sizes.
Bear in mind that the greater the difference in the sample sizes, the less robust a t-test is to heterogeneity of variance. With your sample sizes, of 25 and 240, I would automatically use an "unequal variances" t-test. I.e., use either Welch's t-test or the Satterthwaite t-test. Which one is most easily available to you might depend on what software you use. HTH.