I am trying to get a better understanding of relational databases and there is something that I keep bumping into and don’t understand. Let’s take this two tables:

In this case Login.ID is the primary key with auto_increment set and Profile.ID_LOGIN is the foreign key. When a user is created and its username and password are stored in the login database does the ID corresponding to the current username and password get automatically added into ID_LOGIN or do I have to create a SQL statement to do this?
If I have to create a SQL statement how should I approach adding the ID_LOGIN to make sure I am adding it correctly?
Strictly speaking, having a foreign key is just a field in one table which is a place to store a reference to a record in another table. So your code has to populate both tables and set the foreign key.
Databases have features for foreign key constraints, which are helpful to forbid database operations which would leave a foreign key where there is no record in the other table referenced by the value in the foreign key.
The really handy thing about maintaining a foreign key in an SQL database is that you can easily do a join to get the related data when you need it in a query.
BTW, Ruby on Rails manages foreign keys for you using associations. So if you program in Ruby on Rails, it will set the foreign keys for you and often do the joins you need.