As a witness, they may question the child; however, the child may leave at any time and does not have to answer questions.
As a suspect not in custody, the child has to right to leave at anytime and not answer any questions.
As a suspect in custody (meaning the child has been told they are not free to leave), the child has the right to call and inform his parents or his whereabouts, the right to not answer questions, the right to have an attorney (and if he cannot afford one, then the right to have one appointed by the State).
It sounds like your child was a witness. In the future, let your child know he does not have to answer any questions and should ask to leave or have you present anytime he is called into the office.
CPS can question anyone at any time without notifying anyone. Often then will attempt to get the parents to bring the child in for questioning but if the parent is not cooperative, they will simply go to the school to talk to the child. They are not considered law enforcement but have the duty to protect the best interest of the child.
The sheriff's department or any other law enforcement can question a person of any age at any time without notifying anyone except that if that person is a suspect in a crime, they must give them legal warnings. That said, a child of 4 or 5 cannot be charged with a crime in Texas.
Although I have answered the question to try to help you, you should consult with a lawyer in your area in person on the matter. In addition, my answer does not establish an attorney-client relationship between us.