There is a huge debate around this, but my opinion is that the salt should be added to the pasta water just before adding the pasta, once the water reaches a rolling boil. This allows the salt to dissolve evenly and infuse the pasta with flavor as it cooks. Adding salt too early can prolong the time it takes for the water to boil and may result in uneven seasoning.