Bring a large pot of salted water to a boil and cook the orecchiette according to package directions.
About 5 minutes before the pasta is done, add the broccoli florets to the boiling water so they cook until tender; then drain pasta and broccoli together in a colander.
Return the empty pot to medium heat and add the olive oil. Add the chopped shallots and cook 3–4 minutes until softened and translucent.
Add the minced garlic to the shallots and sauté about 30 seconds to 1 minute until fragrant, then turn off the heat.
Add the drained pasta and broccoli back to the pot and toss to coat evenly in the oil and shallot mixture.
Season with the salt and freshly ground black pepper, add red pepper flakes if using, and toss again.
Stir in the grated Parmesan cheese just before serving and toss to combine.