If you mean for a website, then you turn on the pref in safari (Safari->Preferences->AutoFill and then make sure "User Names and Passwords" is ticked). Then, when you type in a username/password on a website Safari will ask you if you want it remembered. If you say yes it will be added to your keychain for you.