Your question relates to buffers, or solutions which resist changes in pH. Buffers are often used in biochemistry and chemistry and typically are made with a weak acid (only partially dissociates in water) and a soluble salt containing the acid's conjugate base. There are literally hundreds of different buffer systems; each buffer is most useful in the pH range at or close to a value known as the pKa. This is the negative Log (base 10) of the Ka, which is the dissociation constant for the weak acid. In order to calculate pH values of buffers or the amounts of each constituent required for a specific buffer, we need to know the pKa.
The solutions to your questions involve the Henderson-Hasselbalch (H-H) equation (for a derivation of this equation plug its name into an internet ...
The solution solves for the proper amount of HCl to be added to a buffer solution to achieve a required salt acid ratio.