Let G be a group. A subset X of G is a set of pairwise noncommuting elements if xy ̸= yx for any two distinct elements x and y in X. If |X| ≥ |Y | for any other set of pairwise non-commuting elements Y in G, then X is said to be a maximal subset of pairwise non-commuting elements. In this paper we determine the cardinality of a maximal subset of pairwise non-commuting elements in any non-abelian p-groups with central quotient of order less than or equal to p3 for any prime number p. As an immediate consequence we give this cardinality for any non-abelian group of order p4.