Typically, the っ appears when the reading of one kanji ends in つ, but the next begins with a sound that is hard to pronounce following つ. When that happens, the つ is eroded to っ and the combination is easier to pronounce.
Sure, that’s true for words, but still has nothing to do with grammar or sentences. OP seemed confused by the fundamental difference between つ and っ, so I didn’t want to overwhelm them with even more information.
It’s more that it generally occurs when there’s anything that would get naturally reduced over time because it’s hard to say. Onyomi that end in a variety of things other than つ also get rendaku’d.
It’s more “kanji that are difficult to say right before the next kanji” rather than “kanji that end in つ”. For example, 学 (がく) + 校 (こう) becomes がっこう, because がくこう requires you to practically swallow your own tongue to say smoothly enough.
This note about the abrupt stop when its at the end of a word is very nice to know! I’ve seen this before in dialogue and not known what to make of it. Thanks!
Man, no love for Kyoko or Kenichi on this thread …
In addition to the links that @seanblue kindly provided, every (almost every?) vocabulary page on Wanikani has links for audible readings of the word (both female and male). If you ever wonder about how any word on Wanikani is pronounced, those links are worth a click.