Rinsing pasta after boiling is generally recommended only for pasta salads or dishes where you don't want the sauce to cling to the noodles. For hot pasta dishes, avoid rinsing.
Rinsing pasta removes the starchy water that helps sauces adhere to the noodles. When making a hot pasta dish with sauce, you want that starch. The starchy water emulsifies with the sauce, creating a creamy and cohesive dish. However, if you're making a cold pasta salad, rinsing is beneficial. It stops the cooking process, prevents the pasta from sticking together, and cools it down quickly. To rinse, simply drain the pasta in a colander and run cold water over it until it's cool to the touch.
If you accidentally overcook your pasta and need to use it in a hot dish, rinsing it briefly can help remove some of the excess starch and prevent it from becoming too gummy. However, try to avoid overcooking in the first place!