There are two options to capturing the soul of a creature within a soul gem but first a little lesson in mechanics:
Soul Gems can only hold a soul of corresponding or lesser size. The size of the soul is categorized by the general difficulty of the creature. There are 6 sizes of soul gem: Petty, Lesser, Common, Greater, Grand, and Black from smallest to largest. Examples of proper soul sizes:
- Petty-Skeever
- Lesser-Draug
- Common-Troll
- Greater-Giant
- Grand- Dragon Priest
- Black- Humanoid
Obviously, the larger the soul gem the more uncommon they tend to be with blacks bordering on all but impossible to find (at level 31 I have found 3) due to their necromantic nature and the fact that they are considered illegal in most parts of Tamriel. Black soul gems are the only soul gem that can house the soul of a humanoid (khajit, argonian, elf, human, orc).
The larger the soul gem, the greater enchantment they can place on an item and the more charges they can refill.
All that being said back to your two options. You must first of all have an appropriate (or larger) size soul gem in your inventory. Option 1 is to cast a "Soul Trap" spell on an enemy then kill that enemy within the allotted time (typically 30-60 seconds). The other option is to have a weapon with "soul binding" abilities on it. Abilities such as this will be listed on the weapons menu stats. Typically these will have a smaller amount of time to kill the enemy in but should not be concerning since you will likely kill the creature with that same weapon. Once the creature is killed you will see an animation of blue lights and in the top right hand corner of your screen it will say whether or not you successfully harvested the soul depending on whether or not you had a proper sized empty soul gem.