Annabeth is under the influence of a powerful enchantment placed upon her by Luke, who is disguised as a friendly camper. This enchantment causes her to forget who she is and become obedient to Luke's commands.
Percy is initially unaware of the enchantment and believes Annabeth is acting strangely or being deliberately unhelpful. He is frustrated by her actions and even accuses her of being a traitor.
It's not until later in the book that the enchantment is broken, and Annabeth regains her memories. This happens when she hears the sound of the ocean, which triggers a subconscious connection to her heritage and her true identity as a daughter of Athena.
So, while Percy is initially confused and upset by Annabeth's behavior, he does not play a direct role in breaking the enchantment. It's the sound of the ocean that ultimately sets her free.