To manage GCP ops-agent using Terraform, first, configure the Google Cloud provider in your Terraform setup. Then, create a google_compute_instance resource and specify metadata for enabling the ops-agent with the necessary logging and monitoring configurations. Use a startup script in the metadata_startup_script block to install the ops-agent on the virtual machine instances. You can also define additional configuration for ops-agent based on your monitoring needs. Finally, run terraform apply to deploy the resources and configure the ops-agent automatically.