Melt the butter in a medium saucepan over medium heat.
Add the onions and cook until soft, 2-3 minutes.
Stir in the flour and cook, stirring, until it starts to brown, about 2 minutes.
Whisk in the beer until smooth.
Reduce the heat to low and simmer until the beer is cooked out and the sauce is reduced, about 5 minutes.
Stir in the cream and garlic. Stir continuously and cook until the sauce has thickened, 10 minutes.
Remove from heat and season with 1/2 teaspoon salt and a pinch of pepper.
Slowly add the cheeses and stir until melted.
Keep warm over low heat.