This enzyme is secreted by the gastric glands of the stomach.
The bolus which comes into the stomach from the oesophagus gets treated with HCl which kills all germs and also activates the pepsin and thereafter it becomes capable of breaking down the proteins in the food into smaller amino acid chains.
Pepsin remains in an inactive state till the food reaches into the stomach and thereafter it digests the proteins to small peptide chains or amino acids.