If you're self-employed, you pay both portions. You make the payment at the time you pay your income tax. The amount you pay is based on net business income after expenses. You don't have to include any other source of income such as Employment Insurance benefits, Worker's Compensation, investment income, and so on. You contribute to the CPP no matter how often you change jobs or where you work.
Every employer is required to collect CPP contributions from each employee.
The CPP keeps a record of all your contributions paid into the Plan over your working life.