I have recently been asked by several people to provide fashion suggestions for how to dress in professional settings. This is going to be a multipart essay - there is much to cover, and I'll make some more specific suggestions in future posts.
When in professional settings, it is good to dress professionally. Professional settings are defined as one's workplace, a conference, a job interview, giving a talk, etc.
However, defining "professional dress" can be tricky, and selecting the right attire for the organization can be tricky. I have worked for some organizations where professional attire means jeans and T-shirts. But usually professional dress falls somewhere between "business casual" (button-down shirts, nice looking pants, non-boots/non-sneakers*) and "formal" (suit, dress shoes).
The most important aspect of picking the appropriate level of professional attire is this: If you are inside the organization (i.e., employee), dress exactly as everyone else dresses, but if you are outside the organization (i.e., job candidate), dress one level up from what everyone else is wearing.
For example, if you work at an company where all the other employees wear a suit to work every day, you should wear a suit to work every day too. If they wear jeans, you wear jeans. It's all about blending in. You don't want to be noticed for your clothes - you want your clothes to be background noise to your brains.
Now there is one exception here - if you want to get promoted, or seen as able to fulfill a role "higher" than where you currently are, dress a level up. So if you want to be promoted to be a project leader, dress like all the project leaders do. If you want to be hired as a professor, don't dress like a graduate student at conferences. You want to be seen as a peer.
If you are outside an organization, for example, as a job candidate, you want to dress slightly better than what everyone in the organization wears. If they're all wearing jeans and sneakers, go one level up to "business casual". You probably don't want to wear a suit - especially if you're interviewing in Cupertino! If the employees wear a mix of business casual and jeans, then it's reasonable to wear a suit. Once you are employed you can figure out what to wear, but if you're an outsider trying to get in, dress slightly better than everyone.
If you don't know in advance what the standard attire is for the organization, err on the side of formal dress. People (including you!) take you more seriously when you are dressed up - there's peer-reviewed articles on this. :). I know some Computer Scientists who fiercely debate this, and argue that the scruffy person in flip flops and torn jeans is always the smartest person in the room, but take my word - don't be scruffy as an outsider.
(*) Dear CS Men: I beg of you, from the bottom of my heart, please do not wear those sinfully awful black sneakers (c.f. this). I don't know which uber-geek started this trend, but he was wrong to do it - they are a fashion abomination. Go buy yourself a nice pair of Rockports, or something from the Walking Company. If you absolutely must wear sneakers, get a pair of Converse or some trendy Adidas or something.