A Bayesian model for the classical group-testing problem is presented. Lots of size N from which all the defective items have to be removed are submitted for inspection. If the number of defectives, D, is known, then the problem of group testing is to determine the (fixed) group size that minimizes the total inspection per lot for defective rate p = D/N. In this article, we assume that the number of defectives in a lot is a random variable with a Polya distribution. We also derive an optimal two-stage group-testing plan via dynamic programming. It is shown that a variable group size based on a simple updating procedure can reduce inspection substantially compared to a fixed group size based on the mean defective rate and applied to the whole lot.