What's actually happening to your window frame
Carpenter ants found wood that's already a little wet, and they're carving nesting tunnels through it. The window frame is one of the most common spots because it's exposed to weather and it leaks before you notice.
They don't eat the wood. They excavate it, so the damage looks like clean, smooth chambers rather than mud-packed tunnels. The shavings get pushed out through small openings and pile up as frass below the sill.
Here's the part that catches people off guard. The window frame is usually a satellite nest, and the main colony sits outside in a stump or wet timber nearby. Treat only what you can see and you'll be doing this again next year.
Why they picked this window
Carpenter ants don't attack sound, dry wood. Something softened that frame first, and in most cases it's water.
The usual culprit is a small leak around the flashing or a failed caulk joint at the top corners of the window. Water gets behind the trim, the wood stays damp, and over a season or two it starts to rot. That's the invitation.
Sometimes the leak isn't at the window at all. A clogged gutter or a downspout dumping next to the wall soaks the sheathing, and the moisture wicks into the framing until the ants find it.
In older homes (say, anything built before the mid-1990s with solid wood windows), joints that were never resealed open up over decades and let water creep in. Those homes get hit more often, and usually at multiple windows.
Vegetation matters too. Branches touching the roof or shrubs pressed against the siding give ants a direct path and trap moisture against the wall.