An example of a sub domain is keyword.example.com. An example of a sub directory is example.com/keyword.
In general, most sites should use sub directories because their website is on one topic. But when your website is on multiple topics you should use sub domains.
For example, let’s say you have a blog about entrepreneurship and know you want to talk about stocks and investing. If you want to place that content on your website you may want to consider placing it on a sub domain.
If you have a large website that is popular and high in authority, such as a site like Huffington Post, you can put everything in a sub directory, but in general, you want your website to only be on one topic.
If it is on one topic, use sub directories and if it is on multiple topics consider using sub domains.