How do you have to activate an open source license? Just including the text of the license in all files?
I don't know what the exact legal requirement is, but normal practice is to include a small header comment at the start of each file:
- that states who owns the copyright, and
- that states that the file is covered by such-and-such a license, telling the reader the name of the file that contains the text of the license, and telling them where to find the text if the file is missing.
What else do I have to do? Do I need to buy some right?
Include a readme.txt in all the directories?
No. A single README file in the root of the directory tree is a good idea, but not mandatory.
I mean, what do I have to do if I want my code is protected by the legal test of a license?
To be absolutely sure, talk to a lawyer.
Concerning your licensing requirements.
(1) I don't care what people do with my code, educational purposes, to make money, I don't mind whatever they want to do with it.
That is kind of a non-requirement. Very few licenses forbid people from making money, use in education, etc.
However "do what they like with it" literally contradicts some of your other requirements.
(2) If they change my code and someone ask for those modifications, they give the code with the modifications.
The requirement that they provide the source code of any modifications that they make is present in GPL, LGPL, AGPL, but not in Apache, BSD, and other common licenses.
(3) But I want people don't delete my name from the code, and If they use my code force them to mention me.
Most licenses require attributions in the code to remain in the code.
However "force them to mention me" is difficult, and few if any licenses say that. Indeed the FSF position is that such a requirement makes your code non-free ...
(4) But I don't want to force people to publish the code of they applications, even if they are using my code.
Few licenses force people to publish the code of their application as a matter of course. Even the most radical of the GPL family allows you to use and modify software for purely private purposes.
However GPL et al do force people to publish the source if people distribute an application based on yours. (The precise conditions depend on the license. For example, LGPL allows people to link their code with yours without forcing them to publish theirs. On the other hand GPL requires them to publish their code in those circumstances, and AGPL extends this to other areas.)
Note also, that requirement (2) and (4) are literally contradictory.
In summary, you need to be able express your requirements for a license clearly. If you can't do that, then you've little chance in finding a license that matches your requirements.
Or maybe you should just talk to a lawyer. (He / she will obviously need to ask you a bunch of questions to elicit what your real requirements are.)