It's from Rambam, Hilchot Teshuva 3:4:
"..לְפִיכָךְ צָרִיךְ כָּל אָדָם שֶׁיִּרְאֶה עַצְמוֹ כָּל הַשָּׁנָה כֻּלָּהּ כְּאִלּוּ חֶצְיוֹ זַכַּאי וְחֶצְיוֹ חַיָּב. וְכֵן כָּל הָעוֹלָם חֶצְיוֹ זַכַּאי וְחֶצְיוֹ חַיָּב. חָטָא חֵטְא אֶחָד הֲרֵי הִכְרִיעַ אֶת עַצְמוֹ וְאֶת כָּל הָעוֹלָם כֻּלּוֹ לְכַף חוֹבָה וְגָרַם לוֹ הַשְׁחָתָה. עָשָׂה מִצְוָה אַחַת הֲרֵי הִכְרִיעַ אֶת עַצְמוֹ וְאֶת כָּל הָעוֹלָם כֻּלּוֹ לְכַף זְכוּת וְגָרַם לוֹ וְלָהֶם תְּשׁוּעָה וְהַצָּלָה..."
"It is, therefore, necessary for every man to behold himself throughout the whole year in a light of being evenly balanced between innocence and guilt, and look upon the entire world as if evenly balanced between innocence and guilt; thus, if he commit one sin, he will overbalance himself and the whole world to the side of guilt, and be a cause of its destruction; but if he perform one duty, behold, he will overbalance himself and the whole world to the side of virtue, and bring about his own and their salvation and escape..."
As noted by @Alex, this is based on the gemara in Kiddushin 40:
"The Sages taught: Always a person should view himself as though he were exactly half-liable and half-meritorious. In other words he should act as though the plates of his scale are balanced, so that if he performs one mitzva he is fortunate, as he tilts his balance to the scale of merit. If he transgresses one prohibition, woe to him, as he tilts his balance to the scale of liability, as it is stated: “But one sin destroys much good” (Ecclesiastes 9:18), which means that due to one sin that a person transgresses he squanders much good. Rabbi Elazar, son of Rabbi Shimon, says: Since the world is judged by its majority, i.e., depending on whether people have performed a majority of mitzvot or a majority of sins, and an individual is likewise judged by his majority, each person must consider that if he performs one mitzva he is praiseworthy, as he tilts the balance of himself and the entire world to the scale of merit. Conversely, if he transgresses one prohibition, woe to him, as he tilts the balance for himself and the entire world to the scale of liability, as it is stated: “But one sin destroys much good,” i.e., due to one sin that this individual commits, he squanders much goodness from himself and from the entire world."