<?xml version="1.0"?>
<ownershipDocument>

    <schemaVersion>X0508</schemaVersion>

    <documentType>4</documentType>

    <periodOfReport>2024-11-19</periodOfReport>

    <issuer>
        <issuerCik>0000878927</issuerCik>
        <issuerName>OLD DOMINION FREIGHT LINE, INC.</issuerName>
        <issuerTradingSymbol>ODFL</issuerTradingSymbol>
    </issuer>

    <reportingOwner>
        <reportingOwnerId>
            <rptOwnerCik>0001067863</rptOwnerCik>
            <rptOwnerName>CONGDON EARL E</rptOwnerName>
        </reportingOwnerId>
        <reportingOwnerAddress>
            <rptOwnerStreet1>C/O OLD DOMINION FREIGHT LINE, INC.</rptOwnerStreet1>
            <rptOwnerStreet2>500 OLD DOMINION WAY</rptOwnerStreet2>
            <rptOwnerCity>THOMASVILLE</rptOwnerCity>
            <rptOwnerState>NC</rptOwnerState>
            <rptOwnerZipCode>27360</rptOwnerZipCode>
            <rptOwnerStateDescription></rptOwnerStateDescription>
        </reportingOwnerAddress>
        <reportingOwnerRelationship>
            <isOfficer>true</isOfficer>
            <officerTitle>Chair Emeritus &amp; Sr. Advisor</officerTitle>
        </reportingOwnerRelationship>
    </reportingOwner>

    <aff10b5One>false</aff10b5One>

    <nonDerivativeTable>
        <nonDerivativeTransaction>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <transactionDate>
                <value>2024-11-19</value>
            </transactionDate>
            <transactionCoding>
                <transactionFormType>4</transactionFormType>
                <transactionCode>I</transactionCode>
                <equitySwapInvolved>0</equitySwapInvolved>
            </transactionCoding>
            <transactionAmounts>
                <transactionShares>
                    <value>7577</value>
                </transactionShares>
                <transactionPricePerShare>
                    <value>211.8</value>
                </transactionPricePerShare>
                <transactionAcquiredDisposedCode>
                    <value>D</value>
                </transactionAcquiredDisposedCode>
            </transactionAmounts>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>68205</value>
                    <footnoteId id="F1"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By 401(k) plan</value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeTransaction>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>0</value>
                    <footnoteId id="F2"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>D</value>
                </directOrIndirectOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>2213016</value>
                    <footnoteId id="F3"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By Earl E. Congdon Trust - 1990</value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>1867428</value>
                    <footnoteId id="F4"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By Earl E. Congdon GRAT Remainder Trust</value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
        <nonDerivativeHolding>
            <securityTitle>
                <value>Common Stock</value>
            </securityTitle>
            <postTransactionAmounts>
                <sharesOwnedFollowingTransaction>
                    <value>707100</value>
                    <footnoteId id="F5"/>
                </sharesOwnedFollowingTransaction>
            </postTransactionAmounts>
            <ownershipNature>
                <directOrIndirectOwnership>
                    <value>I</value>
                </directOrIndirectOwnership>
                <natureOfOwnership>
                    <value>By wife as trustee of the Kathryn W. Congdon Trust - 1990</value>
                </natureOfOwnership>
            </ownershipNature>
        </nonDerivativeHolding>
    </nonDerivativeTable>

    <footnotes>
        <footnote id="F1">On March 28, 2024, the common stock of Old Dominion Freight Line, Inc. began trading on a 2-for-1 stock split-adjusted basis, resulting in the reporting person's ownership of 37,842 additional shares of common stock.</footnote>
        <footnote id="F2">On March 28, 2024, the common stock of Old Dominion Freight Line, Inc. began trading on a 2-for-1 stock split-adjusted basis, resulting in the reporting person's ownership of 906 additional shares of common stock. Amount also reflects an exempt transfer of 1,812 shares since the reporting person's last Form 4.</footnote>
        <footnote id="F3">On March 28, 2024, the common stock of Old Dominion Freight Line, Inc. began trading on a 2-for-1 stock split-adjusted basis, resulting in the reporting person's ownership of 1,105,602 additional shares of common stock. Amount also reflects an exempt transfer of 1,812 shares since the reporting person's last Form 4.</footnote>
        <footnote id="F4">On March 28, 2024, the common stock of Old Dominion Freight Line, Inc. began trading on a 2-for-1 stock split-adjusted basis, resulting in the reporting person's ownership of 933,714 additional shares of common stock.</footnote>
        <footnote id="F5">On March 28, 2024, the common stock of Old Dominion Freight Line, Inc. began trading on a 2-for-1 stock split-adjusted basis, resulting in the reporting person's ownership of 353,550 additional shares of common stock.</footnote>
    </footnotes>

    <ownerSignature>
        <signatureName>/s/ Earl E. Congdon</signatureName>
        <signatureDate>2024-11-20</signatureDate>
    </ownerSignature>
</ownershipDocument>
