Moving your king into check (i.e. where it can be captured) is called an "illegal move".
If you are playing a casual game then you should put the position back to what it was before the illegal move was made and make a legal move.
If you are playing in a competition then more formal rules apply as specified in the sections of the FIDE Laws of Chess from article 6 onwards.
In a competition you play with clocks and the illegal move only counts as "completed" if you pressed the clock after making the illegal move. If you have not pressed the clock then you should just take the move back, play a legal move with the touched piece if possible and continue the game.
If you have completed the move by pressing the clock then you must also take the move back and play a legal move with the piece touched if possible but then additional penalties apply. These are spelled out in article 7.5.5:
7.5.5 After the action taken under Article 7.5.1, 7.5.2, 7.5.3 or 7.5.4 for the first completed illegal move by a player, the arbiter shall give two minutes extra time to his opponent; for the second
completed illegal move by the same player the arbiter shall declare
the game lost by this player. However, the game is drawn if the
position is such that the opponent cannot checkmate the player’s king
by any possible series of legal moves.
These rules apply for all competition chess regardless of time control. Regardless of whether it is standard, rapid or blitz a second illegal move loses the game.
The only difference between standard time controls on one hand and blitz and rapid on the other is in determining that an illegal move has been made. In standard the moves are recorded and it is possible to detect an illegal move several moves later and also to return to the position before the illegal move. In the two quicker forms where moves are not recorded (world championships may differ in the respect that moves are recorded and so standard rules apply) and so slightly different rules apply regarding detecting that an illegal move has been made.
These are spelled out in Appendix A.4.2:
A.4.2 If the arbiter observes an action taken under Article 7.5.1, 7.5.2, 7.5.3 or 7.5.4, he shall act according to Article 7.5.5, provided the opponent has not made his next move. If the arbiter does
not intervene, the opponent is entitled to claim, provided the
opponent has not made his next move. If the opponent does not claim
and the arbiter does not intervene, the illegal move shall stand and
the game shall continue. Once the opponent has made his next move, an
illegal move cannot be corrected unless this is agreed by the players
without intervention of the arbiter.
So, in rapid and blitz the illegal move must be spotted immediately. If any more moves are made then the illegal move stands and the game continues. If the move is spotted by either the opponent or the arbiter then the normal rules apply and a second illegal move loses the game unless it is impossible for the opponent to mate.