From Gill's Commentary"
Acts 18:18
For he had a vow; this, some think, could not be the vow of the Nazarites, for then he should have stayed till he came to Jerusalem, and have shaved his head at the door of the tabernacle of the congregation, and cast the hair into the fire, under the pot in which the peace offerings were boiled (b); though he that vowed in the country, was not obliged to this: others think it was such an one as the Jews in travelling used, that they would not shave till they came to such a place; and so the apostle had made a vow that he would shave at Cenchrea; and accordingly did; but this is not likely, that the apostle should make a vow upon so light an occasion: others that it refers to his going to Jerusalem, to keep the feast there, Act_18:21 and so these think the words are a reason, not of his shaving of his head, but of his sailing to Syria; the first is most probable, that it was a Nazarite's vow; see Acts 21:24.
Acts 21:24
That they may shave their heads; according to the law in Num_6:18. This was done in לשכת הנזירים, the chamber of the Nazarites (r); for there the Nazarites boiled their peace offerings, and shaved their hair, and put it under the pot, in the fire that was under it: Maimonides says (s),
"if he shaved in the city it was excusable; but whether he shaved in the city or in the sanctuary, under the pot his hair must be cast; and he did not shave until the door of the court was opened, as it is said, "at the door of the tabernacle of the congregation", Num_6:18 not that he shaved over against the door, for that would be a contempt of the sanctuary.''
Moreover, it may be observed, that a person who had not made a vow, or fulfilled a Nazariteship himself, which was the apostle's case, yet he might join in bearing the expenses of others, at the time of their shaving and cleansing: for so run the Jewish canons (t);
"he that says, upon me be the shaving of a Nazarite, he is bound to bring the offerings of shaving for purification, and he may offer them by the hand of what Nazarite he pleases; he that says, upon me be half the offerings of a Nazarite, or if he says, upon me be half the shaving of a Nazarite, he brings half the offerings by what Nazarite he will, and that Nazarite perfects his offerings out of that which is his.''
Barnes and others agree on this point.